-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
117 lines (103 loc) · 3.24 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
cmake_minimum_required(VERSION 3.20)
# Disable CYGWIN Legacy Warning
set(CMAKE_LEGACY_CYGWIN_WIN32 0)
# Set where .dll should go
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY $<1:${CMAKE_SOURCE_DIR}>/lib)
# Set all version configuration
set(VERSION_MAJOR 0)
set(VERSION_MINOR 3)
set(VERSION_PATCH 0)
set(SO_VERSION ${VERSION_MAJOR}.${VERSION_MINOR})
set(FULL_VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH})
# Project info
project(HSGIL VERSION ${FULL_VERSION})
# Project options
option(HSGIL_BUILD_SHARED "Build HSGIL in shared mode [Static by default]." OFF)
option(HSGIL_BUILD_EXAMPLES "Build HSGIL examples." OFF)
option(HSGIL_FORCE_GLX_CTX_VERSION OFF)
set(HSGIL_GLX_CTX_VERSION_MAJOR 4 CACHE STRING "Specifies Forced GLX Version Major")
set(HSGIL_GLX_CTX_VERSION_MINOR 6 CACHE STRING "Specifies Forced GLX Version Minor")
option(HSGIL_DEV_OPT_1 OFF) # VLD on Windows
# Set C++17 as the standard
set(CMAKE_CXX_STANDARD 17)
# Set generic lib name
set(HSGIL_LIB_NAME hsgil)
include(GNUInstallDirs)
if(WIN32)
set(HSGIL_PLATFORM win32)
else()
set(HSGIL_PLATFORM linux)
endif()
# Get Source Files
set(HSGIL_SOURCES
external/src/glad/glad.c
src/system/timer.cpp
src/system/${HSGIL_PLATFORM}/timerPlatform.cpp
src/graphics/gUtils.cpp
src/graphics/mesh.cpp
src/graphics/model.cpp
src/graphics/shader.cpp
src/math/mUtils.cpp
src/math/vecArithmetic.cpp
src/window/inputHandler.cpp
src/window/renderingWindow.cpp
src/window/${HSGIL_PLATFORM}/windowManagerPlatform.cpp
src/window/${HSGIL_PLATFORM}/compatUtilsPlatform.cpp
src/window/wmLazyPtr.cpp
src/window/wUtils.cpp
)
# Buil library
if(HSGIL_BUILD_SHARED)
add_library(${HSGIL_LIB_NAME} SHARED ${HSGIL_SOURCES})
else()
add_library(${HSGIL_LIB_NAME} STATIC ${HSGIL_SOURCES})
endif()
set_target_properties(${HSGIL_LIB_NAME}
PROPERTIES
VERSION ${PROJECT_VERSION}
SOVERSION ${SO_VERSION}
PUBLIC_HEADER include/HSGIL/hsgil.hpp
)
configure_file(${HSGIL_LIB_NAME}.pc.in ${HSGIL_LIB_NAME}.pc @ONLY)
# Set Dynamic Compile Definitions
set(HSGIL_COMPILE_DEFINITIONS C__HSGIL_COMPILING)
if(HSGIL_FORCE_GLX_CTX_VERSION)
set(HSGIL_COMPILE_DEFINITIONS ${HSGIL_COMPILE_DEFINITIONS}
C__HSGIL_FORCE_GLX_CTX_VERSION
C__HSGIL_GLX_CTX_VERSION_MAJOR=${HSGIL_GLX_CTX_VERSION_MAJOR}
C__HSGIL_GLX_CTX_VERSION_MINOR=${HSGIL_GLX_CTX_VERSION_MINOR}
)
endif()
if(HSGIL_BUILD_SHARED)
target_compile_definitions(${HSGIL_LIB_NAME}
PUBLIC
GLAD_GLAPI_EXPORT
PRIVATE
__STDC_LIB_EXT1__
${HSGIL_COMPILE_DEFINITIONS}
C__HSGIL_SHARED_LIB
GLAD_GLAPI_EXPORT_BUILD
)
else()
target_compile_definitions(${HSGIL_LIB_NAME}
PRIVATE
__STDC_LIB_EXT1__
${HSGIL_COMPILE_DEFINITIONS}
)
endif()
target_include_directories(${HSGIL_LIB_NAME} PRIVATE include)
install(TARGETS ${HSGIL_LIB_NAME}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)
install(FILES ${CMAKE_BINARY_DIR}/${HSGIL_LIB_NAME}.pc
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/pkgconfig
)
if(WIN32)
target_link_libraries(${HSGIL_LIB_NAME} opengl32)
else()
target_link_libraries(${HSGIL_LIB_NAME} GL X11)
endif()
if(HSGIL_BUILD_EXAMPLES)
add_subdirectory(examples)
endif()