From 09fe744de0f99eecf317d7dbc8866fa9dccca55f Mon Sep 17 00:00:00 2001 From: James Turner Date: Sun, 26 Mar 2017 12:15:29 +0100 Subject: [PATCH] Test helper CMake macro. Also build the test code first, so tests can reside in source tree as well as the test tree. Finally, build local Sqlite with -fpic to give consistent linkage when using either built-in or system sqlite. --- 3rdparty/sqlite3/CMakeLists.txt | 2 +- CMakeLists.txt | 5 +++-- tests/CMakeLists.txt | 16 ++++++++-------- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/3rdparty/sqlite3/CMakeLists.txt b/3rdparty/sqlite3/CMakeLists.txt index cf1036fb4..8ddae70e3 100644 --- a/3rdparty/sqlite3/CMakeLists.txt +++ b/3rdparty/sqlite3/CMakeLists.txt @@ -2,4 +2,4 @@ add_definitions(-DSQLITE_OMIT_LOAD_EXTENSION) add_definitions(-DNDEBUG) add_library(fgsqlite3 sqlite3.c) -set_target_properties(fgsqlite3 PROPERTIES COMPILE_FLAGS "-fno-fast-math") +set_target_properties(fgsqlite3 PROPERTIES COMPILE_FLAGS "-fpic -fno-fast-math") diff --git a/CMakeLists.txt b/CMakeLists.txt index 0d7e2ac37..b83550e22 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -509,8 +509,6 @@ configure_file ( add_subdirectory(3rdparty) add_subdirectory(utils) -add_subdirectory(src) -add_subdirectory(man) if(ENABLE_TESTS) # enable CTest / make test target @@ -528,6 +526,9 @@ else() message(STATUS "Tests: DISABLED") endif(ENABLE_TESTS) +add_subdirectory(src) +add_subdirectory(man) + #----------------------------------------------------------------------------- ### uninstall target #----------------------------------------------------------------------------- diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index af4842a31..3033669d5 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -94,16 +94,16 @@ if(FG_HAVE_GPERFTOOLS) include_directories(${GooglePerfTools_INCLUDE_DIR}) target_link_libraries(fgtestlib ${GooglePerfTools_LIBRARIES}) endif() -target_link_libraries(fgtestlib SimGearCore ${PLATFORM_LIBS}) +target_link_libraries(fgtestlib SimGearCore ${PLATFORM_LIBS} ${SQLITE3_LIBRARY}) add_executable(fgtest fgTestDriver.cxx) target_link_libraries(fgtest fgtestlib) -# repeat this section for each unit-test executable -add_executable(testnavs test_navaids2.cxx) -target_link_libraries(testnavs fgtestlib ${SQLITE3_LIBRARY}) -add_test(testnavs ${EXECUTABLE_OUTPUT_PATH}/testnavs) +macro(flightgear_test name sources) + add_executable(${name} ${sources}) + target_link_libraries(${name} fgtestlib) + add_test(${name} ${EXECUTABLE_OUTPUT_PATH}/${name}) +endmacro() -add_executable(testflightplan test_flightplan.cxx) -target_link_libraries(testflightplan fgtestlib ${SQLITE3_LIBRARY}) -add_test(testflightplan ${EXECUTABLE_OUTPUT_PATH}/testflightplan) +flightgear_test(test_navs test_navaids2.cxx) +flightgear_test(test_flightplan test_flightplan.cxx)