-
Notifications
You must be signed in to change notification settings - Fork 4
/
CMakeLists.txt
91 lines (68 loc) · 2.61 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
CMAKE_MINIMUM_REQUIRED(VERSION 3.5)
################################
# Init of project
################################
project(cpp_zia)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
if(MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /std:c++20")
endif(MSVC)
################################
# Build Modules
################################
add_subdirectory(SrcModules/Network)
add_subdirectory(SrcModules/Php)
add_subdirectory(SrcModules/Router)
################################
# Build Zia Core
################################
if (MSVC)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG "${CMAKE_BINARY_DIR}")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE "${CMAKE_BINARY_DIR}")
endif()
include_directories(includes api lib)
file(GLOB_RECURSE SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp)
add_executable(cpp_zia ${SOURCE_FILES})
target_link_libraries (cpp_zia ${CMAKE_THREAD_LIBS_INIT})
################################
# Testing
################################
if (BUILD_TESTS)
if (APPLE)
add_definitions(-DGTEST_USE_OWN_TR1_TUPLE)
add_definitions(-D__GLIBCXX__)
endif (APPLE)
file(COPY CMakeLists.txt.in DESTINATION .)
configure_file(CMakeLists.txt.in googletest-download/CMakeLists.txt)
execute_process(COMMAND "${CMAKE_COMMAND}" -G "${CMAKE_GENERATOR}" .
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/googletest-download" )
execute_process(COMMAND "${CMAKE_COMMAND}" --build .
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/googletest-download" )
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
add_subdirectory("${CMAKE_BINARY_DIR}/googletest-src"
"${CMAKE_BINARY_DIR}/googletest-build")
##############
# Unit Tests
##############
file(GLOB_RECURSE TEST_SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/tests/*.cpp)
file(GLOB_RECURSE T_SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp)
list(REMOVE_ITEM T_SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/main.cpp)
set(CMAKE_CXX_FLAGS "-g --coverage -O0 -Wall -fprofile-arcs -ftest-coverage")
set(CMAKE_CXX_OUTPUT_EXTENSION_REPLACE 1)
if(MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /std:c++17")
endif(MSVC)
add_executable(runUnitTests ${TEST_SOURCE_FILES} ${T_SOURCE_FILES})
if (UNIX AND NOT APPLE)
target_link_libraries(runUnitTests stdc++fs)
target_link_libraries(runUnitTests ${CMAKE_DL_LIBS})
endif()
if (UNIX)
target_link_libraries(runUnitTests gtest gtest_main pthread)
elseif (MSVC)
target_link_libraries(runUnitTests gtest gtest_main)
endif()
enable_testing()
add_test(NAME runUnitTests COMMAND runUnitTests)
endif()