cmake - How do I detect that I am cross-compiling in CMakeLists.txt? -
the cmake documentation suggests cmake_crosscompiling set when cross-compiling. in cmakelists.txt have lines:
if(cmake_crosscompiling) message(status "cross-compiling skipping unit tests.") option(game_portal_unit_test "enable unit testing of game portal code" off) else() message(status "enabling unit testing of game portal code") option(game_portal_unit_test "enable unit testing of game portal code" on) endif()
the output running:
cmake -dcmake_toolchain_file=../crosscompile/raspberry_pi/cmakecross.txt .
includes text "enabling unit testing of game portal code", variable not being set, or not evaluates true anyway.
i tried modifying cmakecross.txt include:
set(cmake_crosscompiling on cache bool "cross-compiling" force)
and after cleaning old cmakecache.txt , rerunning cmake command can see new cmakecache.txt includes variable, still same result regards unit tests being enabled.
how can reliably detect cross-compiling can disable unit tests?
as requested, full cross-compile file is:
# set minimum cmake version required cross-compiling work. cmake_minimum_required(version 2.6) # build rm cmakecache.txt; cmake -dcmake_toolchain_file=/home/crosscompile/dev/raspberry_pi/cmakecross.txt .. # set target system name. set (cmake_system_name linux) # set compiler name. set (cmake_c_compiler arm-linux-gnueabihf-gcc) set (cmake_cxx_compiler arm-linux-gnueabihf-g++) # set path(s) search libraries/binaries/headers. set (cmake_find_root_path /home/crosscompile/dev/raspberry_pi/rootfs/) # ensure cross-compiler directories searched. set (only_cmake_find_root_path true) # search programs in build host directories set(cmake_find_root_path_mode_program never) # libraries , headers in target directories set(cmake_find_root_path_mode_library only) set(cmake_find_root_path_mode_include only) # set output/install directory safe place. set (cmake_install_prefix /home/crosscompile/dev/raspberry_pi/install/) set(cmake_exe_linker_flags "${cmake_exe_linker_flags} -rpath-link=/lib/arm-linux-gnueabihf") set(threads_pthread_arg 0) set(cmake_crosscompiling on cache bool "cross-compiling" force)
with in-source builds, 1 need manually cleanup build files when change configuration parameters lot.
e.g., if did native build before, , decide cross-compile, need perform manual cleanup: cmake cannot automatically adjust build directory 1 build type another.
this 1 of reasons why in-source builds not recommended , should replaced out-of-source builds.
Comments
Post a Comment