This repository has been archived by the owner on Jan 3, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathCMakeLists.txt
90 lines (68 loc) · 3.57 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
cmake_minimum_required(VERSION 2.8.2 FATAL_ERROR)
project(collabserver-grapheditor)
message(STATUS "Building project ${PROJECT_NAME}")
if("${PROJECT_SOURCE_DIR}" STREQUAL "${PROJECT_BINARY_DIR}")
message(FATAL_ERROR "in-source build not allowed. Use another directory.")
endif()
# Compiler Flags
message(STATUS "Detected Operating System: ${CMAKE_SYSTEM_NAME}")
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
if(NOT CMAKE_BUILD_TYPE)
message(WARNING "No CMAKE_BUILD_TYPE set for ${PROJECT_NAME}: uses default Release")
message(WARNING "Available build types: Debug Release RelWithDebInfo MinSizeRel")
set(CMAKE_BUILD_TYPE Release)
endif()
message(STATUS "CMAKE_BUILD_TYPE for ${PROJECT_NAME}: ${CMAKE_BUILD_TYPE}")
# Dependencies
message(STATUS "Adding dependencies for ${PROJECT_NAME}")
add_subdirectory("${PROJECT_SOURCE_DIR}/extern/cJSON-1.7.14")
include_directories("${PROJECT_SOURCE_DIR}/extern/cJSON-1.7.14")
add_subdirectory("${PROJECT_SOURCE_DIR}/gitmodules/collabserver-client")
include_directories("${PROJECT_SOURCE_DIR}/gitmodules/collabserver-client/include")
add_subdirectory("${PROJECT_SOURCE_DIR}/gitmodules/collabserver-datatypes")
include_directories("${PROJECT_SOURCE_DIR}/gitmodules/collabserver-datatypes/include")
include_directories("${PROJECT_SOURCE_DIR}/extern/msgpack-c-3.3.0/include") # Header only
# GraphEditor Executable
message(STATUS "Building GraphEditor executable")
include_directories("${PROJECT_SOURCE_DIR}/src/")
file(GLOB_RECURSE srcFilesExecutable "${PROJECT_SOURCE_DIR}/src/*.cpp")
add_executable(${PROJECT_NAME}-exe ${srcFilesExecutable})
target_link_libraries(${PROJECT_NAME}-exe collabserver-client-lib cjson curl)
add_custom_target(run ${PROJECT_NAME}-exe)
# Copy resources folder
set(RESOURCES_SRC "${PROJECT_SOURCE_DIR}/resources/")
set(RESOURCES_BIN "${PROJECT_BINARY_DIR}/resources/")
add_custom_command(
OUTPUT "${RESOURCES_BIN}"
DEPENDS "${RESOURCES_SRC}"
COMMAND ${CMAKE_COMMAND} -E copy_directory ${RESOURCES_SRC} ${RESOURCES_BIN}
)
add_custom_target(copyResources ALL DEPENDS "${RESOURCES_BIN}")
add_dependencies(run copyResources)
# Tests
option(COLLABSERVER_GRAPHEDITOR_TESTS "Build Tests" OFF)
if(COLLABSERVER_GRAPHEDITOR_TESTS)
message(STATUS "Build tests for ${PROJECT_NAME}")
enable_testing()
include_directories("${PROJECT_SOURCE_DIR}/include/")
file(GLOB_RECURSE srcFilesTests "${PROJECT_SOURCE_DIR}/tests/*.cpp")
file(GLOB_RECURSE srcFilesSimpleGraph "${PROJECT_SOURCE_DIR}/src/simplegraph/*.cpp")
add_executable(${PROJECT_NAME}-tests ${srcFilesTests} ${srcFilesSimpleGraph})
# Googletest dependency
include_directories("${PROJECT_SOURCE_DIR}/extern/googletest/googletest/include/")
add_subdirectory("${PROJECT_SOURCE_DIR}/extern/googletest-1.10.0")
target_link_libraries(${PROJECT_NAME}-tests gtest)
# Lib dependency
target_link_libraries(${PROJECT_NAME}-tests collabserver-client-lib cjson curl)
# Tests target
add_test(NAME googletests COMMAND ${PROJECT_NAME}-tests)
add_custom_target(runTests ${PROJECT_NAME}-tests)
# TODO Temporary disabled
# Add simple test for Mvk (These are more like examples, rather than actual Unit Tests)
#file(GLOB_RECURSE srcFilesTestsMvk "${PROJECT_SOURCE_DIR}/tests/mvk/Test_MvkWrapper.cpp"
# "${PROJECT_SOURCE_DIR}/src/mvk/MvkWrapper.cpp"
# "${PROJECT_SOURCE_DIR}/src/utils/utils.cpp")
#add_executable(${PROJECT_NAME}-testsMvk ${srcFilesTestMvk})
#target_link_libraries(${PROJECT_NAME}-testsMvk collabserver-client-lib cjson curl)
endif()