From b757183f51920e8445ed0ea0bbdb490d99781ec6 Mon Sep 17 00:00:00 2001 From: Vo Trung Chi Date: Wed, 3 Jul 2019 09:41:38 +0700 Subject: cmake-improvements (#135) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. Allow building as a subproject of another cmake project (CMAKE_* vs PROJECT_* variables) 2. Do not generate header files within source – bad practice, use build directory for that(e.g. change location where dlt_version.h is being generated) 3. Use add_compile_options() instead of *_C/CXX_FLAGS variables for proper compile environment definition, also bad practice, also see p.2 4. Add WITH_DLT_PKGCONFIG – add generate pkgconfig .pc files as switchable option, should probably be part of headers install routine. Signed-off-by: Radoslaw Kaczorowski --- tests/CMakeLists.txt | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) (limited to 'tests') diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index c56bb22..609a7a0 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,15 +1,10 @@ # Setup testing enable_testing() -SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -isystem ${gtest_SOURCE_DIR}/include") +#add_compile_options(-g -fsanitize=address) +add_compile_options(-isystem ${gtest_SOURCE_DIR}/include) -#SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g") -#SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address") - -SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++0x") - -configure_file(${CMAKE_SOURCE_DIR}/tests/testfile.dlt ${PROJECT_BINARY_DIR}/tests COPYONLY) -configure_file(${CMAKE_SOURCE_DIR}/tests/testfilter.txt ${PROJECT_BINARY_DIR}/tests COPYONLY) +configure_file(${PROJECT_SOURCE_DIR}/tests/testfile.dlt ${PROJECT_BINARY_DIR}/tests COPYONLY) if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux") set(LIBRARIES gtest gtest_main) @@ -43,8 +38,7 @@ target_link_libraries(gtest_dlt_daemon_gateway ${DLT_DAEMON_LIBRARIES}) target_link_libraries(gtest_dlt_daemon_event_handler ${DLT_DAEMON_LIBRARIES}) target_link_libraries(gtest_dlt_daemon_offline_log ${DLT_DAEMON_LIBRARIES}) -if(${WITH_DLT_CXX11_EXT}) +if(WITH_DLT_CXX11_EXT) add_executable(dlt-test-cpp-extension dlt-test-cpp-extension.cpp) - set_target_properties(dlt-test-cpp-extension PROPERTIES COMPILE_FLAGS "-std=gnu++0x") target_link_libraries(dlt-test-cpp-extension ${DLT_LIBRARIES}) endif() -- cgit v1.2.1