-
Notifications
You must be signed in to change notification settings - Fork 2
/
CMakeLists.txt
94 lines (76 loc) · 2.81 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
cmake_minimum_required(VERSION 3.10)
project(GEngine)
include(GNUInstallDirs)
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
include(cmake/automate-vcpkg.cmake)
if (NOT DEFINED ENV{NOT_INSTALL_VCPKG})
vcpkg_bootstrap()
vcpkg_install_packages(raylib stduuid nlohmann-json portaudio opus bzip2)
endif()
file(GLOB_RECURSE SOURCES source/*.cpp)
list(FILTER SOURCES EXCLUDE REGEX ".*/deprecated/.*")
file(GLOB_RECURSE HEADERS include/*.h)
list(FILTER HEADERS EXCLUDE REGEX ".*/deprecated/.*")
include_directories(include)
# if(NOT WIN32)
# add_compile_options(-Wall -Wextra)
# endif()
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
if (MSVC)
add_compile_options(/D_ITERATOR_DEBUG_LEVEL=0)
endif()
endif()
add_library(GEngine SHARED ${SOURCES} ${HEADERS})
add_library(GEngine_static STATIC ${SOURCES} ${HEADERS})
set(CMAKE_DEBUG_POSTFIX d)
set_target_properties(GEngine PROPERTIES
CXX_STANDARD 20
CXX_STANDARD_REQUIRED YES
CXX_EXTENSIONS NO
DEBUG_POSTFIX ${CMAKE_DEBUG_POSTFIX}
VERSION 0.0.1
)
set_target_properties(GEngine_static PROPERTIES
CXX_STANDARD 20
CXX_STANDARD_REQUIRED YES
CXX_EXTENSIONS NO
DEBUG_POSTFIX ${CMAKE_DEBUG_POSTFIX}
VERSION 0.0.1
OUTPUT_NAME "GEngine-s"
)
find_package(raylib CONFIG REQUIRED)
find_package(glfw3 CONFIG REQUIRED)
find_package(portaudio CONFIG REQUIRED)
find_package(Opus REQUIRED)
find_package(BZip2 REQUIRED)
find_package(stduuid CONFIG REQUIRED)
find_package(nlohmann_json CONFIG REQUIRED)
if(WIN32)
target_link_libraries(GEngine wsock32 ws2_32 portaudio ${OPUS_LIBRARIES} BZip2::BZip2 raylib)
target_link_libraries(GEngine_static PRIVATE stduuid nlohmann_json::nlohmann_json PUBLIC wsock32 ws2_32)
else()
target_link_libraries(GEngine portaudio_static ${OPUS_LIBRARIES} BZip2::BZip2 raylib glfw)
target_link_libraries(GEngine_static PRIVATE stduuid nlohmann_json::nlohmann_json)
endif()
target_compile_definitions(GEngine PRIVATE GENGINE_BUILD)
target_compile_definitions(GEngine_static PRIVATE GENGINE_BUILD)
install(TARGETS GEngine GEngine_static
EXPORT GEngine_targets
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
install(DIRECTORY include/ DESTINATION include)
install(EXPORT GEngine_targets
FILE GEngineTargets.cmake
DESTINATION share/GEngine)
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/GEngineConfig.cmake"
"include(CMakeFindDependencyMacro)\n"
"find_dependency(raylib CONFIG REQUIRED)\n"
"find_dependency(glfw3 CONFIG REQUIRED)\n"
"find_dependency(portaudio REQUIRED)\n"
"find_dependency(Opus REQUIRED)\n"
"find_dependency(BZip2 REQUIRED)\n"
"include(\"\${CMAKE_CURRENT_LIST_DIR}/GEngineTargets.cmake\")\n"
)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/GEngineConfig.cmake"
DESTINATION share/GEngine)