2018-11-20 21:18:40 +08:00
|
|
|
cmake_minimum_required(VERSION 3.5.1)
|
2018-07-04 17:11:49 +08:00
|
|
|
project(libcarla-unit-tests)
|
|
|
|
|
2019-01-27 00:27:14 +08:00
|
|
|
if (CMAKE_BUILD_TYPE STREQUAL "Client")
|
|
|
|
set(carla_config client)
|
|
|
|
elseif (CMAKE_BUILD_TYPE STREQUAL "Server")
|
|
|
|
set(carla_config server)
|
|
|
|
endif ()
|
2020-04-04 01:54:51 +08:00
|
|
|
if (BUILD_RSS_VARIANT)
|
|
|
|
set(carla_target_postfix "_rss")
|
|
|
|
else()
|
|
|
|
set(carla_target_postfix "")
|
|
|
|
endif()
|
2018-07-04 17:11:49 +08:00
|
|
|
|
|
|
|
link_directories(
|
|
|
|
${RPCLIB_LIB_PATH}
|
|
|
|
${GTEST_LIB_PATH})
|
|
|
|
|
2019-01-27 00:27:14 +08:00
|
|
|
file(GLOB libcarla_test_sources
|
|
|
|
"${libcarla_source_path}/carla/profiler/*.cpp"
|
|
|
|
"${libcarla_source_path}/carla/profiler/*.h"
|
|
|
|
"${libcarla_source_path}/test/*.cpp"
|
|
|
|
"${libcarla_source_path}/test/*.h"
|
|
|
|
"${libcarla_source_path}/test/${carla_config}/*.cpp"
|
|
|
|
"${libcarla_source_path}/test/${carla_config}/*.h"
|
|
|
|
"${libcarla_source_path}/test/common/*.cpp"
|
|
|
|
"${libcarla_source_path}/test/common/*.h")
|
|
|
|
|
|
|
|
file(GLOB libcarla_test_client_sources "")
|
|
|
|
|
2019-03-13 21:57:44 +08:00
|
|
|
if (LIBCARLA_BUILD_DEBUG)
|
|
|
|
list(APPEND build_targets libcarla_test_${carla_config}_debug)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if (LIBCARLA_BUILD_RELEASE)
|
|
|
|
list(APPEND build_targets libcarla_test_${carla_config}_release)
|
|
|
|
endif()
|
|
|
|
|
2018-07-04 17:11:49 +08:00
|
|
|
# Create targets for debug and release in the same build type.
|
2019-03-13 21:57:44 +08:00
|
|
|
foreach(target ${build_targets})
|
|
|
|
|
|
|
|
add_executable(${target} ${libcarla_test_sources})
|
|
|
|
|
|
|
|
target_compile_definitions(${target} PUBLIC
|
|
|
|
-DLIBCARLA_ENABLE_PROFILER
|
|
|
|
-DLIBCARLA_WITH_GTEST)
|
|
|
|
|
2019-04-23 18:04:56 +08:00
|
|
|
target_include_directories(${target} SYSTEM PRIVATE
|
2019-03-13 21:57:44 +08:00
|
|
|
"${BOOST_INCLUDE_PATH}"
|
|
|
|
"${RPCLIB_INCLUDE_PATH}"
|
2019-04-23 18:04:56 +08:00
|
|
|
"${GTEST_INCLUDE_PATH}")
|
|
|
|
|
|
|
|
target_include_directories(${target} PRIVATE
|
2019-03-13 21:57:44 +08:00
|
|
|
"${libcarla_source_path}/test")
|
|
|
|
|
|
|
|
if (WIN32)
|
|
|
|
target_link_libraries(${target} "gtest_main.lib")
|
|
|
|
target_link_libraries(${target} "gtest.lib")
|
|
|
|
target_link_libraries(${target} "rpc.lib")
|
|
|
|
else()
|
|
|
|
target_link_libraries(${target} "-lrpc")
|
|
|
|
target_link_libraries(${target} "-lgtest_main")
|
|
|
|
target_link_libraries(${target} "-lgtest")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
install(TARGETS ${target} DESTINATION test OPTIONAL)
|
2018-07-04 17:11:49 +08:00
|
|
|
endforeach(target)
|
|
|
|
|
2019-03-13 21:57:44 +08:00
|
|
|
if (LIBCARLA_BUILD_DEBUG)
|
|
|
|
# Specific options for debug.
|
2019-04-23 22:03:49 +08:00
|
|
|
set_target_properties(libcarla_test_${carla_config}_debug PROPERTIES COMPILE_FLAGS "${CMAKE_CXX_FLAGS_DEBUG}")
|
2020-04-04 01:54:51 +08:00
|
|
|
target_link_libraries(libcarla_test_${carla_config}_debug "carla_${carla_config}${carla_target_postfix}_debug")
|
2019-03-13 21:57:44 +08:00
|
|
|
target_compile_definitions(libcarla_test_${carla_config}_debug PUBLIC -DBOOST_ASIO_ENABLE_BUFFER_DEBUGGING)
|
2019-03-20 05:41:42 +08:00
|
|
|
if (CMAKE_BUILD_TYPE STREQUAL "Client")
|
|
|
|
target_link_libraries(libcarla_test_${carla_config}_debug "${BOOST_LIB_PATH}/libboost_filesystem.a")
|
|
|
|
endif()
|
2019-03-13 21:57:44 +08:00
|
|
|
endif()
|
2018-07-04 17:11:49 +08:00
|
|
|
|
2019-03-13 21:57:44 +08:00
|
|
|
if (LIBCARLA_BUILD_RELEASE)
|
|
|
|
# Specific options for release.
|
2019-04-23 22:03:49 +08:00
|
|
|
set_target_properties(libcarla_test_${carla_config}_release PROPERTIES COMPILE_FLAGS "${CMAKE_CXX_FLAGS_RELEASE}")
|
2020-04-04 01:54:51 +08:00
|
|
|
target_link_libraries(libcarla_test_${carla_config}_release "carla_${carla_config}${carla_target_postfix}")
|
2019-03-20 05:41:42 +08:00
|
|
|
if (CMAKE_BUILD_TYPE STREQUAL "Client")
|
|
|
|
target_link_libraries(libcarla_test_${carla_config}_release "${BOOST_LIB_PATH}/libboost_filesystem.a")
|
|
|
|
endif()
|
2019-03-13 21:57:44 +08:00
|
|
|
endif()
|