1
1
cmake_minimum_required (VERSION 3.0)
2
2
3
3
set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR} /cmake)
4
+ set (CMAKE_EXPORT_COMPILE_COMMANDS ON )
4
5
5
6
# Project
6
7
project (Stronghold)
@@ -13,41 +14,52 @@ endif()
13
14
include_directories (src)
14
15
15
16
# Thirdparty
16
- include_directories (${CMAKE_SOURCE_DIR} /thirdparty/blast/)
17
- include_directories (${CMAKE_SOURCE_DIR} /thirdparty/duktape/)
18
- include_directories (${CMAKE_SOURCE_DIR} /thirdparty/cxxopts/include /)
19
- include_directories (${CMAKE_SOURCE_DIR} /thirdparty/filesystem/include /)
17
+
18
+ # blast
19
+ add_library (blast thirdparty/blast/blast.c)
20
+ set_target_properties (blast PROPERTIES
21
+ INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_SOURCE_DIR} /thirdparty/blast)
22
+
23
+ # cxxopts
24
+ set (CXXOPTS_BUILD_TESTS OFF )
25
+ set (CXXOPTS_BUILD_EXAMPLES OFF )
26
+
27
+ add_subdirectory (thirdparty/cxxopts)
28
+
29
+ # ghc filesystem
30
+ add_subdirectory (thirdparty/filesystem)
20
31
21
32
# pthread
22
- find_package (Threads)
33
+ find_package (Threads REQUIRED )
23
34
24
35
# SDL2
25
36
find_package (SDL2 REQUIRED)
26
- include_directories (${SDL2_INCLUDE_DIR} )
27
37
28
38
# OpenAL
29
39
find_package (OpenAL REQUIRED)
30
- include_directories (${OPENAL_INCLUDE_DIR} )
40
+ add_library (OpenAL::OpenAL UNKNOWN IMPORTED )
41
+ set_target_properties (OpenAL::OpenAL PROPERTIES
42
+ IMPORTED_LOCATION ${OPENAL_LIBRARY}
43
+ INTERFACE_INCLUDE_DIRECTORIES ${OPENAL_INCLUDE_DIR} )
31
44
32
45
# FFmpeg
33
- find_package (FFmpeg REQUIRED)
34
- include_directories ( ${FFMPEG_INCLUDE_DIRS} )
35
- include_directories ( ${SWSCALE_INCLUDE_DIRS} )
46
+ find_package (FFmpeg REQUIRED COMPONENTS
47
+ AVCODEC AVFORMAT AVUTIL SWSCALE )
48
+
36
49
37
50
# swresample
38
51
find_package (Libswresample REQUIRED)
39
- include_directories ( ${LIBSWRESAMPLE_INCLUDE_DIRS} )
52
+ add_library (SWRESAMPLE::SWRESAMPLE UNKNOWN IMPORTED )
53
+ set_target_properties (SWRESAMPLE::SWRESAMPLE PROPERTIES
54
+ IMPORTED_LOCATION ${LIBSWRESAMPLE_LIBRARIES}
55
+ INTERFACE_INCLUDE_DIRECTORIES ${LIBSWRESAMPLE_INCLUDE_DIRS} )
40
56
41
57
# Include sources / headers
42
58
file (
43
59
GLOB_RECURSE _source_list
44
60
LIST_DIRECTORIES false
45
61
"${CMAKE_SOURCE_DIR} /src/*.cpp*"
46
62
"${CMAKE_SOURCE_DIR} /src/*.h*"
47
- "${CMAKE_SOURCE_DIR} /thirdparty/blast/*.c"
48
- "${CMAKE_SOURCE_DIR} /thirdparty/blast/*.h"
49
- "${CMAKE_SOURCE_DIR} /thirdparty/cxxopts/*.c"
50
- "${CMAKE_SOURCE_DIR} /thirdparty/cxxopts/*.h"
51
63
)
52
64
53
65
foreach (_source IN ITEMS ${_source_list} )
@@ -57,31 +69,41 @@ foreach(_source IN ITEMS ${_source_list})
57
69
source_group ("${_group_path} " FILES "${_source} " )
58
70
endforeach ()
59
71
72
+ add_executable (Stronghold ${_source_list} )
73
+
74
+
60
75
if (MSVC )
61
- add_definitions ( -D_CRT_SECURE_NO_WARNINGS)
76
+ target_compile_options (Stronghold PRIVATE -D_CRT_SECURE_NO_WARNINGS)
62
77
foreach ( OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES} )
63
78
string ( TOUPPER ${OUTPUTCONFIG} OUTPUTCONFIG )
64
79
set ( CMAKE_RUNTIME_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${CMAKE_BINARY_DIR} )
65
80
set ( CMAKE_LIBRARY_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${CMAKE_BINARY_DIR} )
66
81
set ( CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${CMAKE_BINARY_DIR} )
67
82
endforeach ( OUTPUTCONFIG CMAKE_CONFIGURATION_TYPES )
68
83
else ()
69
- add_definitions (-Wno-reorder -pedantic-errors -Ofast -fno-fast-math)
84
+ target_compile_options (Stronghold PRIVATE
85
+ -Wno-reorder
86
+ -pedantic-errors
87
+ -Ofast
88
+ -fno-fast-math)
70
89
endif ()
71
90
72
- add_executable (Stronghold ${_source_list} )
73
91
set_target_properties (Stronghold PROPERTIES
74
92
CXX_STANDARD 11
75
93
CXX_STANDARD_REQUIRED YES
76
94
CXX_EXTENSIONS NO
77
95
)
78
96
79
- target_link_libraries (
80
- Stronghold
81
- ${SDL2_LIBRARY}
82
- ${OPENAL_LIBRARY}
83
- ${FFMPEG_LIBRARIES}
84
- ${SWSCALE_LIBRARIES}
85
- ${LIBSWRESAMPLE_LIBRARIES}
86
- ${CMAKE_THREAD_LIBS_INIT}
97
+ target_link_libraries (Stronghold
98
+ PRIVATE Threads::Threads
99
+ PRIVATE SDL2::SDL2
100
+ PRIVATE OpenAL::OpenAL
101
+ PRIVATE FFMPEG::AVCODEC
102
+ PRIVATE FFMPEG::AVFORMAT
103
+ PRIVATE FFMPEG::AVUTIL
104
+ PRIVATE FFMPEG::SWSCALE
105
+ PRIVATE SWRESAMPLE::SWRESAMPLE
106
+ PRIVATE blast
107
+ PRIVATE cxxopts
108
+ PRIVATE ghc_filesystem
87
109
)
0 commit comments