forked from invor/glowl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
61 lines (45 loc) · 1.82 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
cmake_minimum_required(VERSION 3.10 FATAL_ERROR)
project(glowl VERSION 0.4.0 LANGUAGES CXX)
# Build options
set(GLOWL_OPENGL_INCLUDE "NONE" CACHE STRING "Choose OpenGL include.")
set_property(CACHE GLOWL_OPENGL_INCLUDE PROPERTY STRINGS "NONE" "GLAD" "GLAD2" "GL3W" "GLEW")
# The library
add_library(glowl INTERFACE)
add_library(glowl::glowl ALIAS glowl)
target_include_directories(glowl INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>)
if (NOT GLOWL_OPENGL_INCLUDE STREQUAL "NONE")
target_compile_definitions(glowl INTERFACE
"GLOWL_OPENGL_INCLUDE_${GLOWL_OPENGL_INCLUDE}")
endif ()
# Install
include(GNUInstallDirs)
install(DIRECTORY include/
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
install(TARGETS glowl EXPORT glowlTargets)
install(EXPORT glowlTargets
FILE glowlConfig.cmake
NAMESPACE glowl::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/glowl)
include(CMakePackageConfigHelpers)
write_basic_package_version_file(
${CMAKE_CURRENT_BINARY_DIR}/glowlConfigVersion.cmake
VERSION ${PACKAGE_VERSION}
COMPATIBILITY SameMinorVersion)
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/glowlConfigVersion.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/glowl)
export(TARGETS glowl NAMESPACE glowl:: FILE glowlConfig.cmake)
# Show files in Visual Studio.
if (MSVC)
# Find files.
file(GLOB_RECURSE header_files RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
"${CMAKE_CURRENT_SOURCE_DIR}/include/*.h"
"${CMAKE_CURRENT_SOURCE_DIR}/include/*.hpp")
# Generate new fake target with underscore suffix to show files.
add_custom_target(${PROJECT_NAME}_ SOURCES ${header_files})
# Enable folders and set fake target as default project.
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT ${PROJECT_NAME}_)
endif ()