-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
90 lines (77 loc) · 3.36 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
cmake_minimum_required(VERSION 3.16)
project(rendercat VERSION 0.1)
cmake_policy(SET CMP0077 NEW)
#SET(BUILD_SHARED_LIBS ON)
message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
include(CTest)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
include(CheckIPOSupported)
check_ipo_supported(RESULT RENDERCAT_IS_IPO_SUPPORTED)
if (NOT RENDERCAT_IS_IPO_SUPPORTED)
message(STATUS "LTO not supported for this compiler")
endif()
option(RENDERCAT_WITHOUT_LTO "Do not use LTO in release" OFF)
if (NOT RENDERCAT_WITHOUT_LTO)
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_RELEASE ON)
set(CMAKE_DISABLE_PRECOMPILE_HEADERS ON)
if (CMAKE_BUILD_TYPE MATCHES Release)
message(STATUS "Using LTO in release build")
if (CMAKE_CXX_COMPILER_ID MATCHES GNU)
message(STATUS "Cannot use GCC LTO with LLD or LLVM-AR; disabling both.")
set(RENDERCAT_WITHOUT_LLVM_AR ON)
set(RENDERCAT_WITHOUT_LLD ON)
endif()
endif()
endif()
if(CMAKE_CXX_COMPILER_ID MATCHES Clang|GNU AND NOT CMAKE_CXX_SIMULATE_ID)
# use thin archives for speed, don't update index (ranlib will do it afterwards)
set(CMAKE_CXX_ARCHIVE_CREATE "<CMAKE_AR> cruTS <TARGET> <LINK_FLAGS> <OBJECTS>")
set(CMAKE_CXX_ARCHIVE_APPEND "<CMAKE_AR> ruTS <TARGET> <LINK_FLAGS> <OBJECTS>")
set(CMAKE_C_ARCHIVE_CREATE "<CMAKE_AR> cruTS <TARGET> <LINK_FLAGS> <OBJECTS>")
set(CMAKE_C_ARCHIVE_APPEND "<CMAKE_AR> ruTS <TARGET> <LINK_FLAGS> <OBJECTS>")
option(RENDERCAT_WITHOUT_LLD "Do not use LLD linker" OFF)
option(RENDERCAT_WITHOUT_LLVM_AR "Do not use LLVM-AR archiver" OFF)
if (CMAKE_CXX_COMPILER_ID MATCHES GNU AND CMAKE_SYSTEM_NAME MATCHES Windows)
# on windows GNU ar(1) and ranlib(1) are very slow,
# so attempt to find llvm-ar(1), which is much faster.
find_program(LLVM_AR_PROGRAM llvm-ar)
if (LLVM_AR_PROGRAM AND NOT RENDERCAT_WITHOUT_LLVM_AR)
message(STATUS "Using LLVM-AR as archiver and ranlib")
set(CMAKE_AR "${LLVM_AR_PROGRAM}")
set(CMAKE_RANLIB "${LLVM_AR_PROGRAM}")
# llvm-ranlib does not recognize thin archives, use llvm-ar instead
set(CMAKE_C_ARCHIVE_FINISH "<CMAKE_AR> sT <TARGET>")
set(CMAKE_CXX_ARCHIVE_FINISH "<CMAKE_AR> sT <TARGET>")
endif()
endif()
if (CMAKE_CXX_COMPILER_ID MATCHES Clang)
set(CMAKE_AR "${CMAKE_CXX_COMPILER_AR}")
set(CMAKE_RANLIB "${CMAKE_CXX_COMPILER_RANLIB}")
# llvm-ranlib does not recognize thin archives, use llvm-ar instead
set(CMAKE_C_ARCHIVE_FINISH "<CMAKE_AR> sT <TARGET>")
set(CMAKE_CXX_ARCHIVE_FINISH "<CMAKE_AR> sT <TARGET>")
endif()
# try to find and use lld(1), it's much faster than ld(1)
find_program(LLD_PROGRAM ld.lld)
if (LLD_PROGRAM AND NOT RENDERCAT_WITHOUT_LLD)
message(STATUS "Using LLD linker")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=lld")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fuse-ld=lld")
set(RENDERCAT_WITH_LLD TRUE)
endif()
endif()
find_package(OpenGL REQUIRED)
option(USE_SYSTEM_GLBINDING "Use installed glbinding instead of subproject" OFF)
if (USE_SYSTEM_GLBINDING)
find_package(glbinding REQUIRED)
endif()
add_subdirectory(third_party)
add_subdirectory(rendercat)
add_subdirectory(shaders)
add_dependencies(${PROJECT_NAME} shaders)
add_dependencies(${PROJECT_NAME} shaders-includes)