Reputation: 313
Given a CMakeList.txt
which I cannot edit, can I set CMAKE_TRY_COMPILE_TARGET_TYPE
to be STATIC_LIBRARY
while configuring that file?
Ideally I could do this via an environmental variable, but if that is not possible, passing in my value as a command line argument would be ok too.
I am trying to build a Conan profile that will allow me to cross build using the GNU Arm Embedded Toolchain.
Conan provides a mechanism for specifying the compiler binary and compiler + linker flags I would like CMake to use, but I need to specify set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
in order for GNU Arm Embedded to pass CMake's compiler check.
In order to get my cross build toolchain to work, then, I am left with 2 options:
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
. This is annoying because it forces all projects to have to think about being embedded.CMAKE_TRY_COMPILE_TARGET_TYPE
to CMake without editing the CMakeList.txt
.I would like to do 2.
Upvotes: 2
Views: 3803
Reputation: 1386
You may be able to get the functionality you're looking for with the -D
flag.
I would try something like this: cmake -D CMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY
Upvotes: 3