-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCMakeLists.txt
144 lines (97 loc) · 4.17 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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
cmake_minimum_required(VERSION 3.5.1)
project(libdansdl2)
option(BUILD_STATIC "generate static release" ON)
option(BUILD_SHARED "generate shared release" ON)
option(BUILD_DEBUG "set the release as debug" OFF)
option(BUILD_TESTS "Build test code" OFF)
#library version and naming...
set(MAJOR_VERSION 3)
set(MINOR_VERSION 2)
set(PATCH_VERSION 1)
if(${BUILD_DEBUG})
set(RELEASE_VERSION "debug")
else()
set(RELEASE_VERSION "prod")
endif()
if(${CMAKE_VERSION} VERSION_LESS "3.22.0")
add_definitions(-DMAJOR_VERSION=${MAJOR_VERSION})
add_definitions(-DMINOR_VERSION=${MINOR_VERSION})
add_definitions(-DPATCH_VERSION=${PATCH_VERSION})
add_definitions(-DRELEASE_VERSION=\"${RELEASE_VERSION}\")
else()
add_compile_definitions(MAJOR_VERSION=${MAJOR_VERSION})
add_compile_definitions(MINOR_VERSION=${MINOR_VERSION})
add_compile_definitions(PATCH_VERSION=${PATCH_VERSION})
add_compile_definitions(RELEASE_VERSION=\"${RELEASE_VERSION}\")
endif()
#generic compile options.
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
add_compile_options(-Wall -Wextra -Wundef -Wcast-align -Wwrite-strings -Wlogical-op -Wmissing-declarations -Wredundant-decls -Wshadow -Woverloaded-virtual -Wno-deprecated -ansi -pedantic -fno-rtti)
#Add the include directories
#The cache thing means that this is user settable from the command line.
include_directories("include")
set(SOURCE "")
add_subdirectory("${PROJECT_SOURCE_DIR}/lib")
#library type and filenames.
if(${BUILD_DEBUG})
set(CMAKE_BUILD_TYPE Debug)
set(LIB_FILENAME "dansdl2_debug")
else()
set(CMAKE_BUILD_TYPE Release)
set(LIB_FILENAME "dansdl2")
endif()
if(${BUILD_STATIC})
add_library(dansdl2_static STATIC ${SOURCE})
set_target_properties(dansdl2_static PROPERTIES OUTPUT_NAME ${LIB_FILENAME})
target_compile_definitions(dansdl2_static PUBLIC "-DLIB_VERSION=\"static\"")
install(TARGETS dansdl2_static DESTINATION lib)
message("will build ${MAJOR_VERSION}.${MINOR_VERSION}.${PATCH_VERSION}-${RELEASE_VERSION}-static")
if(${BUILD_DEBUG})
target_compile_definitions(dansdl2_static PUBLIC "-DLIBDANSDL2_DEBUG")
endif()
endif()
if(${BUILD_SHARED})
add_library(dansdl2_shared SHARED ${SOURCE})
set_target_properties(dansdl2_shared PROPERTIES OUTPUT_NAME ${LIB_FILENAME})
target_compile_definitions(dansdl2_shared PUBLIC "-DLIB_VERSION=\"shared\"")
install(TARGETS dansdl2_shared DESTINATION lib)
message("will build ${MAJOR_VERSION}.${MINOR_VERSION}.${PATCH_VERSION}-${RELEASE_VERSION}-shared")
if(${BUILD_DEBUG})
target_compile_definitions(dansdl2_shared PUBLIC "-DLIBDANSDL2_DEBUG")
endif()
endif()
#windows specifics
if(WIN32)
add_compile_definitions(WINBUILD=1)
if(${BUILD_STATIC})
target_compile_definitions(dansdl2_static PUBLIC -DWINBUILD)
target_link_libraries(dansdl2_static lm SDL2 SDL2_ttf SDL2_mixer SDL2_image glu32 opengl32 stdc++fs)
endif()
if(${BUILD_SHARED})
target_compile_definitions(dansdl2_shared PUBLIC -DWINBUILD)
target_link_libraries(dansdl2_shared lm SDL2 SDL2_ttf SDL2_mixer SDL2_image glu32 opengl32 stdc++fs)
endif()
if(${BUILD_DEBUG})
target_compile_definitions(dansdl2_debug PUBLIC -DWINBUILD)
target_link_libraries(dansdl2_debug lm SDL2 SDL2_ttf SDL2_mixer SDL2_image glu32 opengl32 stdc++fs)
endif()
include_directories("${CMAKE_CURRENT_LIST_DIR}/../log/include/")
add_library(lm SHARED IMPORTED)
set_target_properties(lm PROPERTIES IMPORTED_IMPLIB "C:/Program Files (x86)/lm/lib/liblm.dll")
endif()
install(DIRECTORY include/ DESTINATION include)
if(WIN32)
# target_link_libraries(dansdl2_static lm SDL2 SDL2_ttf SDL2_mixer SDL2_image freeglut glew32 glu32 opengl32 stdc++fs)
# target_link_libraries(dansdl2_shared lm SDL2 SDL2_ttf SDL2_mixer SDL2_image freeglut glew32 glu32 opengl32 stdc++fs)
endif()
if(BUILD_TESTS)
if(!${BUILD_SHARED})
message(FATAL_ERROR "The shared library must be built to build the examples!")
endif()
add_executable(input_filter tests/drivers/input_events.cpp)
target_link_libraries(input_filter dansdl2_shared lm SDL2 SDL2_image SDL2_ttf SDL2_mixer GL pthread)
add_executable(gl_version tests/drivers/gl_version.cpp)
target_link_libraries(gl_version dansdl2_shared lm SDL2 SDL2_image SDL2_ttf SDL2_mixer GL pthread)
endif()