-
Notifications
You must be signed in to change notification settings - Fork 5
/
CMakeLists.txt
103 lines (78 loc) · 3.74 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
92
93
94
95
96
97
98
99
100
101
102
103
CMAKE_MINIMUM_REQUIRED(VERSION 3.2)
PROJECT(GOAP)
OPTION(LIBGOAP_EXTERNAL_BUILD "LIBGOAP_EXTERNAL_BUILD" OFF)
OPTION(LIBGOAP_EXTERNAL_CONFIG_INCLUDE "LIBGOAP_EXTERNAL_CONFIG_INCLUDE" OFF)
OPTION(LIBGOAP_INSTALL "LIBGOAP_INSTALL" OFF )
OPTION(LIBGOAP_BUILD_TEST "LIBGOAP_BUILD_TEST" ON)
SET(LIBGOAP_EXTERNAL_CONFIG_INCLUDE_PATH "" CACHE STRING "LIBGOAP_EXTERNAL_CONFIG_INCLUDE_PATH")
MESSAGE("LIBGOAP_EXTERNAL_BUILD: ${LIBGOAP_EXTERNAL_BUILD}")
MESSAGE("LIBGOAP_EXTERNAL_CONFIG_INCLUDE: ${LIBGOAP_EXTERNAL_CONFIG_INCLUDE}")
MESSAGE("LIBGOAP_INSTALL: ${LIBGOAP_INSTALL}")
MESSAGE("LIBGOAP_BUILD_TEST: ${LIBGOAP_BUILD_TEST}")
MESSAGE("LIBGOAP_EXTERNAL_CONFIG_INCLUDE_PATH: ${LIBGOAP_EXTERNAL_CONFIG_INCLUDE_PATH}")
IF(NOT LIBGOAP_EXTERNAL_BUILD)
set(CMAKE_CXX_STANDARD 17)
if(${CMAKE_CXX_COMPILER_ID} STREQUAL Clang)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Werror")
elseif(${CMAKE_CXX_COMPILER_ID} STREQUAL AppleClang)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Werror")
elseif(${CMAKE_CXX_COMPILER_ID} STREQUAL GNU)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Werror")
elseif(${CMAKE_CXX_COMPILER_ID} STREQUAL Intel)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Werror")
elseif(${CMAKE_CXX_COMPILER_ID} STREQUAL MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4 /WX /EHsc")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4710")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4738")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4820")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4711")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4250")
endif()
SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/lib/${CMAKE_GENERATOR})
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/bin/${CMAKE_GENERATOR})
ENDIF()
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
SET(PUBLIC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include)
SET(PRIVATE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src)
file(GLOB files_public_headers ${PUBLIC_DIR}/GOAP/*.h)
file(GLOB files_private_headers ${PRIVATE_DIR}/*.h)
file(GLOB files_private_sources ${PRIVATE_DIR}/*.cpp)
IF(LIBGOAP_EXTERNAL_CONFIG_INCLUDE)
file(GLOB files_config_headers ${LIBGOAP_EXTERNAL_CONFIG_INCLUDE_PATH}/GOAP/*.h)
include_directories(${PROJECT_NAME} ${LIBGOAP_EXTERNAL_CONFIG_INCLUDE_PATH})
ELSE()
file(GLOB files_config_headers ${PUBLIC_DIR}/Config/GOAP/*.h)
include_directories(${PROJECT_NAME} ${PUBLIC_DIR}/Config)
ENDIF()
SOURCE_GROUP(Interface FILES ${files_public_headers})
SOURCE_GROUP(Config FILES ${files_config_headers})
SOURCE_GROUP(Headers FILES ${files_private_headers})
SOURCE_GROUP(Sources FILES ${files_private_sources})
include_directories(${PROJECT_NAME} ${PUBLIC_DIR})
add_library(${PROJECT_NAME} STATIC ${files_public_headers} ${files_private_headers} ${files_private_sources} ${files_config_headers})
if(LIBGOAP_INSTALL)
install(DIRECTORY include
DESTINATION .
FILES_MATCHING PATTERN "*.hpp" PATTERN "*.h")
install(TARGETS ${PROJECT_NAME}
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib)
endif()
if(LIBGOAP_BUILD_TEST)
SET(SANDBOX_DIR ${CMAKE_CURRENT_SOURCE_DIR}/sandbox)
set(Sandbox_SOURCES
${SANDBOX_DIR}/main.cpp
${SANDBOX_DIR}/Scheduler.cpp
${SANDBOX_DIR}/Scheduler.h
${SANDBOX_DIR}/TaskDelay.cpp
${SANDBOX_DIR}/TaskDelay.h
${SANDBOX_DIR}/TaskPrint.cpp
${SANDBOX_DIR}/TaskPrint.h
${SANDBOX_DIR}/TaskRoll.cpp
${SANDBOX_DIR}/TaskRoll.h
)
ADD_DEFINITIONS(-D_CRT_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS)
INCLUDE_DIRECTORIES(Sandbox ${PUBLIC_DIR})
ADD_EXECUTABLE(Sandbox ${Sandbox_SOURCES})
TARGET_LINK_LIBRARIES(Sandbox ${PROJECT_NAME})
endif()