summaryrefslogtreecommitdiff
path: root/indra/cmake
diff options
context:
space:
mode:
authorNicky Dasmijn <nicky.dasmijn@posteo.nl>2022-09-17 17:14:16 +0200
committerNicky Dasmijn <nicky.dasmijn@posteo.nl>2022-09-17 17:14:16 +0200
commit8e0b039e554e320cedfdef3057a3073a493db2e7 (patch)
tree78c1bc7e8d773d4f2fd3153f0f42089da90704e5 /indra/cmake
parent8c1427c39f90a322d4069162636e4ee433b664fb (diff)
Cleanup sweep
Diffstat (limited to 'indra/cmake')
-rw-r--r--indra/cmake/LLAddBuildTest.cmake283
-rw-r--r--indra/cmake/LLMath.cmake5
2 files changed, 143 insertions, 145 deletions
diff --git a/indra/cmake/LLAddBuildTest.cmake b/indra/cmake/LLAddBuildTest.cmake
index fa95e08dcd..408280f0cc 100644
--- a/indra/cmake/LLAddBuildTest.cmake
+++ b/indra/cmake/LLAddBuildTest.cmake
@@ -19,89 +19,88 @@ MACRO(LL_ADD_PROJECT_UNIT_TESTS project sources)
#
# More info and examples at: https://wiki.secondlife.com/wiki/How_to_add_unit_tests_to_indra_code
#
- # WARNING: do NOT modify this code without working with poppy -
+ # WARNING: do NOT modify this code without working with poppy - (2022-09-17: ND, I did not talk to poppy, are we all doomed now?)
# there is another branch that will conflict heavily with any changes here.
-INCLUDE(GoogleMock)
- IF(LL_TEST_VERBOSE)
- MESSAGE("LL_ADD_PROJECT_UNIT_TESTS UNITTEST_PROJECT_${project} sources: ${sources}")
- ENDIF(LL_TEST_VERBOSE)
+ # This here looks weird, but is needed. It will inject GoogleMock into projects that forgot to include `this` (LLAddBuildTest.cmake)
+ # But through some other means have access to this macro
+ include(GoogleMock)
+
+ if(LL_TEST_VERBOSE)
+ message("LL_ADD_PROJECT_UNIT_TESTS UNITTEST_PROJECT_${project} sources: ${sources}")
+ endif()
# Start with the header and project-wide setup before making targets
#project(UNITTEST_PROJECT_${project})
# Setup includes, paths, etc
- SET(alltest_SOURCE_FILES
- ${CMAKE_SOURCE_DIR}/test/test.cpp
- ${CMAKE_SOURCE_DIR}/test/lltut.cpp
- )
- SET(alltest_DEP_TARGETS
- # needed by the test harness itself
- llcommon
- )
-
- SET(alltest_INCLUDE_DIRS
- ${LIBS_OPEN_DIR}/test
+ set(alltest_SOURCE_FILES
+ ${CMAKE_SOURCE_DIR}/test/test.cpp
+ ${CMAKE_SOURCE_DIR}/test/lltut.cpp
)
- SET(alltest_LIBRARIES
+ set(alltest_DEP_TARGETS
+ # needed by the test harness itself
+ llcommon
+ )
+
+ set(alltest_LIBRARIES
llcommon
ll::googlemock
)
- IF(NOT "${project}" STREQUAL "llmath")
+ if(NOT "${project}" STREQUAL "llmath")
# add llmath as a dep unless the tested module *is* llmath!
- LIST(APPEND alltest_DEP_TARGETS
- llmath
- )
- LIST(APPEND alltest_LIBRARIES
- llmath
- )
- ENDIF(NOT "${project}" STREQUAL "llmath")
+ list(APPEND alltest_DEP_TARGETS llmath)
+ list(APPEND alltest_LIBRARIES llmath )
+ endif()
# Headers, for convenience in targets.
- SET(alltest_HEADER_FILES
- ${CMAKE_SOURCE_DIR}/test/test.h
- )
+ set(alltest_HEADER_FILES ${CMAKE_SOURCE_DIR}/test/test.h)
# start the source test executable definitions
- SET(${project}_TEST_OUTPUT "")
- FOREACH (source ${sources})
- STRING( REGEX REPLACE "(.*)\\.[^.]+$" "\\1" name ${source} )
- STRING( REGEX REPLACE ".*\\.([^.]+)$" "\\1" extension ${source} )
- IF(LL_TEST_VERBOSE)
- MESSAGE("LL_ADD_PROJECT_UNIT_TESTS UNITTEST_PROJECT_${project} individual source: ${source} (${name}.${extension})")
- ENDIF(LL_TEST_VERBOSE)
+ set(${project}_TEST_OUTPUT "")
+ foreach (source ${sources})
+ string( REGEX REPLACE "(.*)\\.[^.]+$" "\\1" name ${source} )
+ string( REGEX REPLACE ".*\\.([^.]+)$" "\\1" extension ${source} )
+ if(LL_TEST_VERBOSE)
+ message("LL_ADD_PROJECT_UNIT_TESTS UNITTEST_PROJECT_${project} individual source: ${source} (${name}.${extension})")
+ endif()
#
# Per-codefile additional / external source, header, and include dir property extraction
#
# Source
GET_OPT_SOURCE_FILE_PROPERTY(${name}_test_additional_SOURCE_FILES ${source} LL_TEST_ADDITIONAL_SOURCE_FILES)
- SET(${name}_test_SOURCE_FILES
- ${source}
- tests/${name}_test.${extension}
- ${alltest_SOURCE_FILES}
- ${${name}_test_additional_SOURCE_FILES} )
- IF(LL_TEST_VERBOSE)
- MESSAGE("LL_ADD_PROJECT_UNIT_TESTS ${name}_test_SOURCE_FILES ${${name}_test_SOURCE_FILES}")
- ENDIF(LL_TEST_VERBOSE)
+ set(${name}_test_SOURCE_FILES
+ ${source}
+ tests/${name}_test.${extension}
+ ${alltest_SOURCE_FILES}
+ ${${name}_test_additional_SOURCE_FILES} )
+ if(LL_TEST_VERBOSE)
+ message("LL_ADD_PROJECT_UNIT_TESTS ${name}_test_SOURCE_FILES ${${name}_test_SOURCE_FILES}")
+ endif()
# Headers
GET_OPT_SOURCE_FILE_PROPERTY(${name}_test_additional_HEADER_FILES ${source} LL_TEST_ADDITIONAL_HEADER_FILES)
- SET(${name}_test_HEADER_FILES ${name}.h ${${name}_test_additional_HEADER_FILES})
- LIST(APPEND ${name}_test_SOURCE_FILES ${${name}_test_HEADER_FILES})
- IF(LL_TEST_VERBOSE)
- MESSAGE("LL_ADD_PROJECT_UNIT_TESTS ${name}_test_HEADER_FILES ${${name}_test_HEADER_FILES}")
- ENDIF(LL_TEST_VERBOSE)
- # Include dirs
+ set(${name}_test_HEADER_FILES ${name}.h ${${name}_test_additional_HEADER_FILES})
+ list(APPEND ${name}_test_SOURCE_FILES ${${name}_test_HEADER_FILES})
+ if(LL_TEST_VERBOSE)
+ message("LL_ADD_PROJECT_UNIT_TESTS ${name}_test_HEADER_FILES ${${name}_test_HEADER_FILES}")
+ endif()
+
+ # Setup target
+ add_executable(PROJECT_${project}_TEST_${name} ${${name}_test_SOURCE_FILES})
+
+ # Cannot declare a dependency on ${project} because the executable create above will later declare
+ # add_dependencies( ${project} ${project}_tests)
+ # as such grab ${project}'s interface include dirs and inject them here
+ get_property( ${name}_test_additional_INCLUDE_DIRS TARGET ${project} PROPERTY INTERFACE_INCLUDE_DIRECTORIES )
+ target_include_directories (PROJECT_${project}_TEST_${name} PRIVATE ${${name}_test_additional_INCLUDE_DIRS} )
+
GET_OPT_SOURCE_FILE_PROPERTY(${name}_test_additional_INCLUDE_DIRS ${source} LL_TEST_ADDITIONAL_INCLUDE_DIRS)
- INCLUDE_DIRECTORIES(${alltest_INCLUDE_DIRS} ${${name}_test_additional_INCLUDE_DIRS} )
- IF(LL_TEST_VERBOSE)
- MESSAGE("LL_ADD_PROJECT_UNIT_TESTS ${name}_test_additional_INCLUDE_DIRS ${${name}_test_additional_INCLUDE_DIRS}")
- ENDIF(LL_TEST_VERBOSE)
+ target_include_directories (PROJECT_${project}_TEST_${name} PRIVATE ${${name}_test_additional_INCLUDE_DIRS} )
+ target_include_directories (PROJECT_${project}_TEST_${name} PRIVATE ${LIBS_OPEN_DIR}/test )
- # Setup target
- ADD_EXECUTABLE(PROJECT_${project}_TEST_${name} ${${name}_test_SOURCE_FILES})
- SET_TARGET_PROPERTIES(PROJECT_${project}_TEST_${name} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${EXE_STAGING_DIR}")
+ set_target_properties(PROJECT_${project}_TEST_${name} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${EXE_STAGING_DIR}")
#
# Per-codefile additional / external project dep and lib dep property extraction
@@ -111,92 +110,95 @@ INCLUDE(GoogleMock)
GET_OPT_SOURCE_FILE_PROPERTY(${name}_test_additional_PROJECTS ${source} LL_TEST_ADDITIONAL_PROJECTS)
# Libraries
GET_OPT_SOURCE_FILE_PROPERTY(${name}_test_additional_LIBRARIES ${source} LL_TEST_ADDITIONAL_LIBRARIES)
- IF(LL_TEST_VERBOSE)
- MESSAGE("LL_ADD_PROJECT_UNIT_TESTS ${name}_test_additional_PROJECTS ${${name}_test_additional_PROJECTS}")
- MESSAGE("LL_ADD_PROJECT_UNIT_TESTS ${name}_test_additional_LIBRARIES ${${name}_test_additional_LIBRARIES}")
- ENDIF(LL_TEST_VERBOSE)
+
+ if(LL_TEST_VERBOSE)
+ message("LL_ADD_PROJECT_UNIT_TESTS ${name}_test_additional_PROJECTS ${${name}_test_additional_PROJECTS}")
+ message("LL_ADD_PROJECT_UNIT_TESTS ${name}_test_additional_LIBRARIES ${${name}_test_additional_LIBRARIES}")
+ endif()
+
# Add to project
- TARGET_LINK_LIBRARIES(PROJECT_${project}_TEST_${name} ${alltest_LIBRARIES} ${${name}_test_additional_PROJECTS} ${${name}_test_additional_LIBRARIES} )
+ target_link_libraries(PROJECT_${project}_TEST_${name} ${alltest_LIBRARIES} ${${name}_test_additional_PROJECTS} ${${name}_test_additional_LIBRARIES} )
add_dependencies( PROJECT_${project}_TEST_${name} ${alltest_DEP_TARGETS})
# Compile-time Definitions
GET_OPT_SOURCE_FILE_PROPERTY(${name}_test_additional_CFLAGS ${source} LL_TEST_ADDITIONAL_CFLAGS)
- SET_TARGET_PROPERTIES(PROJECT_${project}_TEST_${name}
- PROPERTIES
- COMPILE_FLAGS "${${name}_test_additional_CFLAGS}"
- COMPILE_DEFINITIONS "LL_TEST=${name};LL_TEST_${name}")
- IF(LL_TEST_VERBOSE)
- MESSAGE("LL_ADD_PROJECT_UNIT_TESTS ${name}_test_additional_CFLAGS ${${name}_test_additional_CFLAGS}")
- ENDIF(LL_TEST_VERBOSE)
-
+ set_target_properties(PROJECT_${project}_TEST_${name}
+ PROPERTIES
+ COMPILE_FLAGS "${${name}_test_additional_CFLAGS}"
+ COMPILE_DEFINITIONS "LL_TEST=${name};LL_TEST_${name}")
+ if(LL_TEST_VERBOSE)
+ message("LL_ADD_PROJECT_UNIT_TESTS ${name}_test_additional_CFLAGS ${${name}_test_additional_CFLAGS}")
+ endif()
+
#
# Setup test targets
#
- SET(TEST_EXE $<TARGET_FILE:PROJECT_${project}_TEST_${name}>)
- SET(TEST_OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/PROJECT_${project}_TEST_${name}_ok.txt)
- SET(TEST_CMD ${TEST_EXE} --touch=${TEST_OUTPUT} --sourcedir=${CMAKE_CURRENT_SOURCE_DIR})
+ set(TEST_EXE $<TARGET_FILE:PROJECT_${project}_TEST_${name}>)
+ set(TEST_OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/PROJECT_${project}_TEST_${name}_ok.txt)
+ set(TEST_CMD ${TEST_EXE} --touch=${TEST_OUTPUT} --sourcedir=${CMAKE_CURRENT_SOURCE_DIR})
# daveh - what configuration does this use? Debug? it's cmake-time, not build time. + poppy 2009-04-19
- IF(LL_TEST_VERBOSE)
- MESSAGE(STATUS "LL_ADD_PROJECT_UNIT_TESTS ${name} test_cmd = ${TEST_CMD}")
- ENDIF(LL_TEST_VERBOSE)
+ if(LL_TEST_VERBOSE)
+ message(STATUS "LL_ADD_PROJECT_UNIT_TESTS ${name} test_cmd = ${TEST_CMD}")
+ endif()
SET_TEST_PATH(LD_LIBRARY_PATH)
LL_TEST_COMMAND(TEST_SCRIPT_CMD "${LD_LIBRARY_PATH}" ${TEST_CMD})
- IF(LL_TEST_VERBOSE)
- MESSAGE(STATUS "LL_ADD_PROJECT_UNIT_TESTS ${name} test_script = ${TEST_SCRIPT_CMD}")
- ENDIF(LL_TEST_VERBOSE)
- # Add test
- ADD_CUSTOM_COMMAND(
- OUTPUT ${TEST_OUTPUT}
- COMMAND ${TEST_SCRIPT_CMD}
- DEPENDS PROJECT_${project}_TEST_${name}
- WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
- )
+ if(LL_TEST_VERBOSE)
+ message(STATUS "LL_ADD_PROJECT_UNIT_TESTS ${name} test_script = ${TEST_SCRIPT_CMD}")
+ endif()
+
+ # Add test
+ add_custom_command(
+ OUTPUT ${TEST_OUTPUT}
+ COMMAND ${TEST_SCRIPT_CMD}
+ DEPENDS PROJECT_${project}_TEST_${name}
+ WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
+ )
# Why not add custom target and add POST_BUILD command?
# Slightly less uncertain behavior
# (OUTPUT commands run non-deterministically AFAIK) + poppy 2009-04-19
- # > I did not use a post build step as I could not make it notify of a
+ # > I did not use a post build step as I could not make it notify of a
# > failure after the first time you build and fail a test. - daveh 2009-04-20
- LIST(APPEND ${project}_TEST_OUTPUT ${TEST_OUTPUT})
- ENDFOREACH (source)
+ list(APPEND ${project}_TEST_OUTPUT ${TEST_OUTPUT})
+ endforeach (source)
# Add the test runner target per-project
# (replaces old _test_ok targets all over the place)
- ADD_CUSTOM_TARGET(${project}_tests ALL DEPENDS ${${project}_TEST_OUTPUT})
- ADD_DEPENDENCIES(${project} ${project}_tests)
+ add_custom_target(${project}_tests ALL DEPENDS ${${project}_TEST_OUTPUT})
+ add_dependencies(${project} ${project}_tests)
ENDMACRO(LL_ADD_PROJECT_UNIT_TESTS)
#*****************************************************************************
# GET_OPT_SOURCE_FILE_PROPERTY
#*****************************************************************************
MACRO(GET_OPT_SOURCE_FILE_PROPERTY var filename property)
- GET_SOURCE_FILE_PROPERTY(${var} "${filename}" "${property}")
- IF("${${var}}" MATCHES NOTFOUND)
- SET(${var} "")
- ENDIF("${${var}}" MATCHES NOTFOUND)
+ get_source_file_property(${var} "${filename}" "${property}")
+ if("${${var}}" MATCHES NOTFOUND)
+ set(${var} "")
+ endif()
ENDMACRO(GET_OPT_SOURCE_FILE_PROPERTY)
#*****************************************************************************
# LL_ADD_INTEGRATION_TEST
#*****************************************************************************
-FUNCTION(LL_ADD_INTEGRATION_TEST
- testname
- additional_source_files
- library_dependencies
-# variable args
- )
+FUNCTION(LL_ADD_INTEGRATION_TEST
+ testname
+ additional_source_files
+ library_dependencies
+ # variable args
+ )
if(TEST_DEBUG)
message(STATUS "Adding INTEGRATION_TEST_${testname} - debug output is on")
- endif(TEST_DEBUG)
+ endif()
- SET(source_files
- tests/${testname}_test.cpp
- ${CMAKE_SOURCE_DIR}/test/test.cpp
- ${CMAKE_SOURCE_DIR}/test/lltut.cpp
- ${additional_source_files}
- )
+ set(source_files
+ tests/${testname}_test.cpp
+ ${CMAKE_SOURCE_DIR}/test/test.cpp
+ ${CMAKE_SOURCE_DIR}/test/lltut.cpp
+ ${additional_source_files}
+ )
- SET(libraries
+ set(libraries
${library_dependencies}
ll::googlemock
)
@@ -204,36 +206,37 @@ FUNCTION(LL_ADD_INTEGRATION_TEST
# Add test executable build target
if(TEST_DEBUG)
message(STATUS "ADD_EXECUTABLE(INTEGRATION_TEST_${testname} ${source_files})")
- endif(TEST_DEBUG)
- ADD_EXECUTABLE(INTEGRATION_TEST_${testname} ${source_files})
- SET_TARGET_PROPERTIES(INTEGRATION_TEST_${testname}
- PROPERTIES
- RUNTIME_OUTPUT_DIRECTORY "${EXE_STAGING_DIR}"
- COMPILE_DEFINITIONS "LL_TEST=${testname};LL_TEST_${testname}"
- )
+ endif()
+
+ add_executable(INTEGRATION_TEST_${testname} ${source_files})
+ set_target_properties(INTEGRATION_TEST_${testname}
+ PROPERTIES
+ RUNTIME_OUTPUT_DIRECTORY "${EXE_STAGING_DIR}"
+ COMPILE_DEFINITIONS "LL_TEST=${testname};LL_TEST_${testname}"
+ )
- # The following was copied to llcorehttp/CMakeLists.txt's texture_load target.
+ # The following was copied to llcorehttp/CMakeLists.txt's texture_load target.
# Any changes made here should be replicated there.
if (WINDOWS)
- SET_TARGET_PROPERTIES(INTEGRATION_TEST_${testname}
- PROPERTIES
- LINK_FLAGS "/debug /NODEFAULTLIB:LIBCMT /SUBSYSTEM:CONSOLE"
- LINK_FLAGS_DEBUG "/NODEFAULTLIB:\"LIBCMT;LIBCMTD;MSVCRT\" /INCREMENTAL:NO"
- LINK_FLAGS_RELEASE ""
- )
- endif (WINDOWS)
+ set_target_properties(INTEGRATION_TEST_${testname}
+ PROPERTIES
+ LINK_FLAGS "/debug /NODEFAULTLIB:LIBCMT /SUBSYSTEM:CONSOLE"
+ )
+ endif ()
# Add link deps to the executable
if(TEST_DEBUG)
message(STATUS "TARGET_LINK_LIBRARIES(INTEGRATION_TEST_${testname} ${libraries})")
- endif(TEST_DEBUG)
- TARGET_LINK_LIBRARIES(INTEGRATION_TEST_${testname} ${libraries})
+ endif()
+
+ target_link_libraries(INTEGRATION_TEST_${testname} ${libraries})
+ target_include_directories (INTEGRATION_TEST_${testname} PRIVATE ${LIBS_OPEN_DIR}/test )
# Create the test running command
- SET(test_command ${ARGN})
- SET(TEST_EXE $<TARGET_FILE:INTEGRATION_TEST_${testname}>)
- LIST(FIND test_command "{}" test_exe_pos)
- IF(test_exe_pos LESS 0)
+ set(test_command ${ARGN})
+ set(TEST_EXE $<TARGET_FILE:INTEGRATION_TEST_${testname}>)
+ list(FIND test_command "{}" test_exe_pos)
+ if(test_exe_pos LESS 0)
# The {} marker means "the full pathname of the test executable."
# test_exe_pos -1 means we didn't find it -- so append the test executable
# name to $ARGN, the variable part of the arg list. This is convenient
@@ -242,26 +245,26 @@ FUNCTION(LL_ADD_INTEGRATION_TEST
# pathname of the test program as the last of its args. You need specify
# {} only if the test program's pathname isn't the last argument in the
# desired command line.
- LIST(APPEND test_command "${TEST_EXE}")
- ELSE (test_exe_pos LESS 0)
+ list(APPEND test_command "${TEST_EXE}")
+ else (test_exe_pos LESS 0)
# Found {} marker at test_exe_pos. Remove the {}...
- LIST(REMOVE_AT test_command test_exe_pos)
+ list(REMOVE_AT test_command test_exe_pos)
# ...and replace it with the actual name of the test executable.
- LIST(INSERT test_command test_exe_pos "${TEST_EXE}")
- ENDIF (test_exe_pos LESS 0)
+ list(INSERT test_command test_exe_pos "${TEST_EXE}")
+ endif()
SET_TEST_PATH(LD_LIBRARY_PATH)
LL_TEST_COMMAND(TEST_SCRIPT_CMD "${LD_LIBRARY_PATH}" ${test_command})
if(TEST_DEBUG)
message(STATUS "TEST_SCRIPT_CMD: ${TEST_SCRIPT_CMD}")
- endif(TEST_DEBUG)
+ endif()
- ADD_CUSTOM_COMMAND(
- TARGET INTEGRATION_TEST_${testname}
- POST_BUILD
- COMMAND ${TEST_SCRIPT_CMD}
- )
+ add_custom_command(
+ TARGET INTEGRATION_TEST_${testname}
+ POST_BUILD
+ COMMAND ${TEST_SCRIPT_CMD}
+ )
# Use CTEST? Not sure how to yet...
# ADD_TEST(INTEGRATION_TEST_RUNNER_${testname} ${TEST_SCRIPT_CMD})
diff --git a/indra/cmake/LLMath.cmake b/indra/cmake/LLMath.cmake
index 893920ae6f..a707c75bc4 100644
--- a/indra/cmake/LLMath.cmake
+++ b/indra/cmake/LLMath.cmake
@@ -1,7 +1,2 @@
# -*- cmake -*-
-set(LLMATH_INCLUDE_DIRS
- ${LIBS_OPEN_DIR}/llmath
- )
-
-set(LLMATH_LIBRARIES llmath)