diff --git a/iceoryx_posh/cmake/cpptoml/CMakeLists.txt b/iceoryx_posh/cmake/cpptoml/CMakeLists.txt index 450088de77..960fbf810e 100644 --- a/iceoryx_posh/cmake/cpptoml/CMakeLists.txt +++ b/iceoryx_posh/cmake/cpptoml/CMakeLists.txt @@ -33,12 +33,6 @@ else() set(CREATE_PATH_COMMAND mkdir -p) endif() -if(DEFINED CMAKE_TOOLCHAIN_FILE) - set(TOOLCHAIN_FILE "-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}") - set(cpptoml_DIR ${CMAKE_BINARY_DIR}/dependencies/install/lib/cmake/cpptoml) - set(cpptoml_DIR ${cpptoml_DIR} CACHE PATH "" FORCE) -endif() - # set download config, source and build paths set(DOWNLOAD_CONFIG_DIR ${CMAKE_BINARY_DIR}/dependencies/cpptoml/download) set(SOURCE_DIR ${CMAKE_BINARY_DIR}/dependencies/cpptoml/src) @@ -72,14 +66,22 @@ if(result) message(WARNING "CMake step [patch] for cpptoml failed: ${result}! Build of cpptoml might fail") endif() -execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" "-DENABLE_LIBCXX=off" "-DCPPTOML_BUILD_EXAMPLES=off" "-DCMAKE_INSTALL_PREFIX=${INSTALL_DIR}" "${TOOLCHAIN_FILE}" "${SOURCE_DIR}" - "-DCMAKE_C_FLAGS_INIT=${CMAKE_C_FLAGS_INIT}" - "-DCMAKE_CXX_FLAGS_INIT=${CMAKE_CXX_FLAGS_INIT}" - "-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}" - "-DCMAKE_C_COMPILER_TARGET=${CMAKE_C_COMPILER_TARGET}" - "-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}" - "-DCMAKE_CXX_COMPILER_TARGET=${CMAKE_CXX_COMPILER_TARGET}" - "-DCMAKE_LINKER=${CMAKE_LINKER}" +set(CMAKE_ADDITIONAL_OPTIONS + "-DCMAKE_C_FLAGS_INIT=${CMAKE_C_FLAGS_INIT}" + "-DCMAKE_CXX_FLAGS_INIT=${CMAKE_CXX_FLAGS_INIT}" + "-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}" + "-DCMAKE_C_COMPILER_TARGET=${CMAKE_C_COMPILER_TARGET}" + "-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}" + "-DCMAKE_CXX_COMPILER_TARGET=${CMAKE_CXX_COMPILER_TARGET}" + "-DCMAKE_LINKER=${CMAKE_LINKER}") + +if(DEFINED CMAKE_TOOLCHAIN_FILE) + list(APPEND CMAKE_ADDITIONAL_OPTIONS "-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}") + set(cpptoml_DIR ${CMAKE_BINARY_DIR}/dependencies/install/lib/cmake/cpptoml) + set(cpptoml_DIR ${cpptoml_DIR} CACHE PATH "" FORCE) +endif() + +execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" "-DENABLE_LIBCXX=off" "-DCPPTOML_BUILD_EXAMPLES=off" "-DCMAKE_INSTALL_PREFIX=${INSTALL_DIR}" "${SOURCE_DIR}" ${CMAKE_ADDITIONAL_OPTIONS} RESULT_VARIABLE result WORKING_DIRECTORY ${BUILD_DIR} ) if(result)