cmake: add option to disable building tests

This commit is contained in:
ThorstenB
2011-11-26 16:39:40 +01:00
parent ec5d067d28
commit 7a52c2fa71
8 changed files with 21 additions and 10 deletions

View File

@@ -53,7 +53,7 @@ endif(NOT CMAKE_BUILD_TYPE)
if(${CMAKE_VERSION} VERSION_GREATER 2.8.4)
include(GNUInstallDirs)
else(${CMAKE_VERSION} VERSION_GREATER 2.8.4)
include(OldGNUInstallDirs)
include(OldGNUInstallDirs)
endif(${CMAKE_VERSION} VERSION_GREATER 2.8.4)
message(STATUS "Library installation directory: ${CMAKE_INSTALL_LIBDIR}")
@@ -62,6 +62,7 @@ option(SIMGEAR_HEADLESS "Set to ON to build SimGear without GUI/graphics support
option(JPEG_FACTORY "Enable JPEG-factory support" OFF)
option(ENABLE_LIBSVN "Set to ON to build SimGear with libsvnclient support" ON)
option(ENABLE_RTI "Set to ON to build SimGear with RTI support" OFF)
option(ENABLE_TESTS "Set to OFF to disable building SimGear's test applications" ON)
if (MSVC)
GET_FILENAME_COMPONENT(PARENT_DIR ${PROJECT_SOURCE_DIR} PATH)
@@ -236,12 +237,14 @@ configure_file (
"${PROJECT_SOURCE_DIR}/simgear/simgear_config_cmake.h.in"
"${PROJECT_BINARY_DIR}/simgear/simgear_config.h"
)
if(ENABLE_TESTS)
# enable CTest / make test target
include (Dart)
enable_testing()
endif(ENABLE_TESTS)
install (FILES ${PROJECT_BINARY_DIR}/simgear/simgear_config.h DESTINATION include/simgear/)
add_subdirectory(simgear)
@@ -255,5 +258,3 @@ CONFIGURE_FILE(
ADD_CUSTOM_TARGET(uninstall
"${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")

View File

@@ -6,6 +6,7 @@ set(SOURCES metar.cxx precipitation.cxx)
simgear_component(environment environment "${SOURCES}" "${HEADERS}")
if(ENABLE_TESTS)
add_executable(test_metar test_metar.cxx)
target_link_libraries(test_metar
sgenvironment sgstructure sgmisc sgdebug
@@ -13,4 +14,5 @@ target_link_libraries(test_metar
${ZLIB_LIBRARY}
${RT_LIBRARY})
add_test(metar ${EXECUTABLE_OUTPUT_PATH}/test_metar)
add_test(metar ${EXECUTABLE_OUTPUT_PATH}/test_metar)
endif(ENABLE_TESTS)

View File

@@ -36,6 +36,7 @@ set(SOURCES
simgear_component(io io "${SOURCES}" "${HEADERS}")
if(ENABLE_TESTS)
add_executable(test_sock socktest.cxx)
target_link_libraries(test_sock sgio sgstructure sgthreads sgdebug
${CMAKE_THREAD_LIBS_INIT}
@@ -75,4 +76,4 @@ target_link_libraries(test_binobj
${RT_LIBRARY})
add_test(binobj ${EXECUTABLE_OUTPUT_PATH}/test_binobj)
endif(ENABLE_TESTS)

View File

@@ -6,7 +6,7 @@ set(SOURCES magvar.cxx coremag.cxx)
simgear_component(magvar magvar "${SOURCES}" "${HEADERS}")
if(ENABLE_TESTS)
add_executable(test_magvar testmagvar.cxx )
target_link_libraries(test_magvar sgmagvar)
endif(ENABLE_TESTS)

View File

@@ -45,6 +45,7 @@ set(SOURCES
simgear_component(math math "${SOURCES}" "${HEADERS}")
if(ENABLE_TESTS)
add_executable(math_test SGMathTest.cxx)
target_link_libraries(math_test sgmath sgstructure sgdebug)
add_test(math ${EXECUTABLE_OUTPUT_PATH}/math_test)
@@ -52,3 +53,4 @@ add_test(math ${EXECUTABLE_OUTPUT_PATH}/math_test)
add_executable(geometry_test SGGeometryTest.cxx)
target_link_libraries(geometry_test sgmath sgstructure sgdebug)
add_test(geometry ${EXECUTABLE_OUTPUT_PATH}/geometry_test)
endif(ENABLE_TESTS)

View File

@@ -32,6 +32,7 @@ set(SOURCES
simgear_component(misc misc "${SOURCES}" "${HEADERS}")
if(ENABLE_TESTS)
add_executable(test_tabbed_values tabbed_values_test.cxx)
add_test(tabbed_values ${EXECUTABLE_OUTPUT_PATH}/test_tabbed_values)
target_link_libraries(test_tabbed_values sgmisc)
@@ -43,4 +44,4 @@ target_link_libraries(test_strings sgmisc)
add_executable(test_path path_test.cxx )
add_test(test_path ${EXECUTABLE_OUTPUT_PATH}/test_path)
target_link_libraries(test_path sgmisc sgdebug)
endif(ENABLE_TESTS)

View File

@@ -22,6 +22,7 @@ set(SOURCES
simgear_component(props props "${SOURCES}" "${HEADERS}")
if(ENABLE_TESTS)
add_executable(test_props props_test.cxx)
target_link_libraries(test_props sgprops sgxml sgstructure sgmisc sgdebug)
add_test(test_props ${EXECUTABLE_OUTPUT_PATH}/test_props)
@@ -29,3 +30,4 @@ add_test(test_props ${EXECUTABLE_OUTPUT_PATH}/test_props)
add_executable(test_propertyObject propertyObject_test.cxx)
target_link_libraries(test_propertyObject sgprops sgstructure sgdebug)
add_test(test_propertyObject ${EXECUTABLE_OUTPUT_PATH}/test_propertyObject)
endif(ENABLE_TESTS)

View File

@@ -18,6 +18,7 @@ set(SOURCES
simgear_component(sound sound "${SOURCES}" "${HEADERS}")
if(ENABLE_TESTS)
set(SOUND_TEST_LIBS
sgsound sgio sgmath sgstructure sgthreads sgtiming sgmisc sgdebug
${CMAKE_THREAD_LIBS_INIT}
@@ -35,3 +36,4 @@ create_test(openal_test1)
create_test(openal_test2)
create_test(openal_test3)
create_test(openal_test4)
endif(ENABLE_TESTS)