12/7/2023 0 Comments Cmake set env variableI have a script that sets all variables needed for the cross-compilation. The result will be identical as to having used a toolchain-file. If you have different targets to support, create different toolchain and use the out-of-source-build with CMake.ĮDIT: One thing you could do is to invoke cmake with the -D-argument setting the variables you want to and having sourced your script before: source environment-setup-powerpc-linuxĬmake -DCMAKE_C_COMPILER=$CC -DCMAKE_CXX_COMPILER=$CXX etc And with CMake's CMAKE_BUILD_TYPE you can switch between Debug and Release compilations without changing the toolchain-file. The basic flags used for the target are fixed quite early in a project - normally. In reality a cmake-toolchain-file does not change that often. When we faced the same issue you have (a toolkit which produces a script so set the compile-environment) we changed the toolkit in a way that it produces a toolchain-file along with the script. The only way to set a compiler and flags to do cross-compilation reliably with CMake is with a toolchain-file as done in the tutorial you have found. That said, setting environment variable prior to calling cmake is often the easiest solution to solve the problem, as in this case: Solution 2 Not sure which ones you have to set, probably the environment ones. To set normal variable, do: set(variable "value") To set the environment variable PATH, do: set(ENV "/home/martink") Otherwise, set command in the cmake script is probably what you want, see the reference manual. Reading through the cmake quick start, you can specify variable on a command line: cmake -DVARIABLE1=value1 -DVARIABLE2=value2.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |