Skip to content

Commit

Permalink
test: handle multi-config generator
Browse files Browse the repository at this point in the history
  • Loading branch information
jcar87 committed Nov 13, 2023
1 parent 4971899 commit 44903f8
Showing 1 changed file with 23 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,37 @@ find_package(Andromeda REQUIRED)

# Ensure that CMake module path is a list with two values:
# - the `orion-module-subfolder` is first, and the one set above (cmake-source-dir/cmake) is second
# Note: on multi-config generators, CMakeDeps will prepend it twice (one for Debug, one for Release)
get_property(is_multi_config GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
if(is_multi_config)
set(_expected_list_size 3)
else()
set(_expected_list_size 2)
endif()

list(LENGTH CMAKE_MODULE_PATH _cmake_module_path_length)
if(NOT _cmake_module_path_length EQUAL 2)
message(STATUS "CMAKE_MODULE_PATH DOES NOT have expected value: ${CMAKE_MODULE_PATH}")
if(NOT _cmake_module_path_length EQUAL ${_expected_list_size})
message(STATUS "CMAKE_MODULE_PATH DOES NOT have expected value 1: ${CMAKE_MODULE_PATH}")
endif()

list(GET CMAKE_MODULE_PATH 0 _cmake_module_path_first_element)
if(NOT _cmake_module_path_first_element MATCHES "^.*orion-module-subfolder$")
message(STATUS "CMAKE_MODULE_PATH DOES NOT have expected value: ${CMAKE_MODULE_PATH}")
message(STATUS "CMAKE_MODULE_PATH DOES NOT have expected value 2: ${_cmake_module_path_first_element}")
endif()

if(is_multi_config)
list(GET CMAKE_MODULE_PATH 1 _cmake_module_path_second_element)
if(NOT _cmake_module_path_second_element MATCHES "^.*orion-module-subfolder$")
message(STATUS "CMAKE_MODULE_PATH DOES NOT have expected value 3: ${_cmake_module_path_second_element}")
endif()
set(_expected_cmake_module_path "${_cmake_module_path_first_element};${_cmake_module_path_second_element};${CMAKE_SOURCE_DIR}/cmake")
else()
set(_expected_cmake_module_path "${_cmake_module_path_first_element};${CMAKE_SOURCE_DIR}/cmake")
endif()

if(CMAKE_MODULE_PATH STREQUAL "${_cmake_module_path_first_element};${CMAKE_SOURCE_DIR}/cmake")
if(CMAKE_MODULE_PATH STREQUAL "${_expected_cmake_module_path}")
message(STATUS "CMAKE_MODULE_PATH has expected value: ${CMAKE_MODULE_PATH}")
else()
message(STATUS "CMAKE_MODULE_PATH DOES NOT have expected value: ${CMAKE_MODULE_PATH}")
message(STATUS "CMAKE_MODULE_PATH DOES NOT have expected value 4: ${CMAKE_MODULE_PATH}")
endif()

0 comments on commit 44903f8

Please sign in to comment.