-
Notifications
You must be signed in to change notification settings - Fork 18
/
CMakeLists.txt
133 lines (119 loc) · 3.38 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
cmake_minimum_required (VERSION 3.11)
project(smk
LANGUAGES CXX
VERSION 1.0.0
)
option(SMK_FETCH_DEPENDENCIES "Set to ON to fetch dependencies" ON)
option(SMK_BUILD_DOCS "Set to ON to build docs" ON)
option(SMK_BUILD_EXAMPLES "Set to ON to build examples" ON)
option(SMK_CLANG_TIDY "Execute clang-tidy" OFF)
option(SMK_ENABLE_INSTALL "Generate the install target" ON)
add_subdirectory(third_party)
add_library(stbimage OBJECT
src/smk/StbImage.cpp
src/smk/StbImage.hpp
)
target_include_directories(stbimage PRIVATE src/smk)
add_library(smk STATIC
include/smk/Audio.hpp
include/smk/BlendMode.hpp
include/smk/Color.hpp
include/smk/Drawable.hpp
include/smk/Font.hpp
include/smk/Framebuffer.hpp
include/smk/Input.hpp
include/smk/OpenGL.hpp
include/smk/Rectangle.hpp
include/smk/RenderState.hpp
include/smk/RenderTarget.hpp
include/smk/Shader.hpp
include/smk/Shape.hpp
include/smk/Sound.hpp
include/smk/SoundBuffer.hpp
include/smk/Sprite.hpp
include/smk/Text.hpp
include/smk/Texture.hpp
include/smk/Touch.hpp
include/smk/Transformable.hpp
include/smk/Vertex.hpp
include/smk/VertexArray.hpp
include/smk/Vibrate.hpp
include/smk/View.hpp
include/smk/Window.hpp
src/smk/Audio.cpp
src/smk/BlendMode.cpp
src/smk/Color.cpp
src/smk/Font.cpp
src/smk/Framebuffer.cpp
src/smk/InputImpl.cpp
src/smk/InputImpl.cpp
src/smk/RenderTarget.cpp
src/smk/Shader.cpp
src/smk/Shape.cpp
src/smk/Sound.cpp
src/smk/SoundBuffer.cpp
src/smk/Sprite.cpp
src/smk/Text.cpp
src/smk/Texture.cpp
src/smk/Touch.cpp
src/smk/Transformable.cpp
src/smk/Vertex.cpp
src/smk/VertexArray.cpp
src/smk/Vibrate.cpp
src/smk/View.cpp
src/smk/Window.cpp
)
add_library(smk::smk ALIAS smk)
target_include_directories(smk
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
PRIVATE
src/
)
# Add as many warning as possible:
if (MSVC)
target_compile_options(smk PRIVATE "/wd4244")
target_compile_options(smk PRIVATE "/wd4267")
target_compile_options(smk PRIVATE "/wd4996")
target_compile_options(smk PRIVATE "/wd4305")
else()
target_compile_options(smk PRIVATE "-Wall")
target_compile_options(smk PRIVATE "-Werror")
target_compile_options(smk PRIVATE "-Wno-sign-compare")
target_compile_options(smk PRIVATE "-Wno-return-type")
endif()
set_property(TARGET smk PROPERTY CXX_STANDARD 17)
if(EMSCRIPTEN)
target_link_libraries(smk PUBLIC "-s USE_GLFW=3")
target_link_libraries(smk PUBLIC "-s USE_WEBGL2=1")
else()
target_link_libraries(smk PUBLIC glfw)
target_link_libraries(smk PUBLIC libglew_static)
target_link_libraries(smk PRIVATE OpenAL)
endif()
target_link_libraries(smk PUBLIC $<BUILD_INTERFACE:glm>)
target_link_libraries(smk PRIVATE freetype)
target_link_libraries(smk PRIVATE libnyquist)
target_link_libraries(smk PRIVATE stbimage)
if(SMK_BUILD_EXAMPLES)
add_subdirectory(examples)
endif()
if(SMK_BUILD_DOCS)
add_subdirectory(doc)
endif()
if (SMK_CLANG_TIDY)
find_program( CLANG_TIDY_EXE NAMES "clang-tidy" DOC "Path to clang-tidy executable" )
if(NOT CLANG_TIDY_EXE)
message(STATUS "clang-tidy not found.")
else()
message(STATUS "clang-tidy found: ${CLANG_TIDY_EXE}")
set_target_properties(smk
PROPERTIES CXX_CLANG_TIDY "${CLANG_TIDY_EXE};-warnings-as-errors=*"
)
endif()
endif()
if(SMK_ENABLE_INSTALL)
include(cmake/smk_install.cmake)
include(cmake/smk_package.cmake)
endif()