forked from GLSL-Debugger/GLSL-Debugger
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
134 lines (120 loc) · 4.57 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
134
cmake_minimum_required(VERSION 2.8.10)
project(glsldb)
option(USE_MESA "Use mesa glsl compiler" OFF)
option(TESTS "Build tests" OFF)
if(TESTS)
enable_testing()
if (CMAKE_CONFIGURATION_TYPES)
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND}
--force-new-ctest-process --output-on-failure
--build-config "$<CONFIGURATION>")
else()
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND}
--force-new-ctest-process --output-on-failure)
endif()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fprofile-arcs -ftest-coverage")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage")
endif()
# path to custom modules
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/CMakeModules;${CMAKE_MODULE_PATH}")
set(MNT_C_FLAGS "")
set(MNT_CXX_FLAGS "")
set(MNT_EXE_FLAGS "")
set(MNT_SHRD_FLAGS "")
# Messages with level lower than OUTPUT_LEVEL will be printed
# Levels: DBGLVL_ERROR = 0, DBGLVL_WARNING,
# DBGLVL_INFO, DBGLVL_INTERNAL_WARNING,
# DBGLVL_COMPILERINFO, DBGLVL_DEBUG,
# DBGLVL_ALL = 6
add_definitions(-DOUTPUT_LEVEL=6)
set(BINARY_DIR "${PROJECT_BINARY_DIR}/bin")
set(LIBRARY_DIR "${PROJECT_BINARY_DIR}/lib")
set(ARCHIVE_DIR "${PROJECT_BINARY_DIR}/lib")
# platform checks
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
set(GLSLDB_LINUX 1)
add_definitions(-DGLSLDB_LINUX -D_GNU_SOURCE)
if(CMAKE_SIZEOF_VOID_P MATCHES "8")
include(CheckCXXCompilerFlag)
check_cxx_compiler_flag("-fPIC" WITH_FPIC)
if(WITH_FPIC)
add_definitions(-fPIC)
endif()
endif()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wfatal-errors -std=c99")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wfatal-errors -Wextra -std=c++0x")
set(CMAKE_EXE_FLAGS "${CMAKE_EXE_FLAGS} -Wl,--warn-unresolved-symbols,--warn-once")
set(CMAKE_SHRD_FLAGS "${CMAKE_SHRD_FLAGS} -Wl,--warn-unresolved-symbols,--warn-once")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g -O0")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -g -O0")
endif()
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(GLSLDB_OSX 1)
add_definitions(-DGLSLDB_OSX)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -std=gnu99")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -std=c++0x")
endif()
if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
set(GLSLDB_WIN 1)
set(LIBRARY_DIR "${PROJECT_BINARY_DIR}/bin")
set(ARCHIVE_DIR "${PROJECT_BINARY_DIR}/bin")
# Add windows target & disable warnings
if(MINGW)
set(GLSLDB_MINGW 1)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wfatal-errors -std=c99")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wfatal-errors -Wextra -std=gnu++0x")
set(CMAKE_EXE_FLAGS "${CMAKE_EXE_FLAGS} -Wl,--warn-unresolved-symbols,--warn-once")
set(CMAKE_SHRD_FLAGS "${CMAKE_SHRD_FLAGS} -Wl,--warn-unresolved-symbols,--warn-once")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g -O0")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -g -O0")
add_definitions(-DGLSLDB_WIN)
else()
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /Od")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /Od")
add_definitions(/DDEBUG=1)
add_definitions(/DGLSLDB_WIN /W3 /D_CRT_SECURE_NO_WARNINGS /wd4005 /wd4996 /wd4291 /nologo)
endif()
endif()
# maintainer mode
set( CMAKE_CXX_FLAGS_MAINTAINER ${MNT_CXX_FLAGS} CACHE STRING
"Flags used by the C++ compiler during maintainer builds."
FORCE )
set( CMAKE_C_FLAGS_MAINTAINER ${MNT_C_FLAGS} CACHE STRING
"Flags used by the C compiler during maintainer builds."
FORCE )
set( CMAKE_EXE_LINKER_FLAGS_MAINTAINER
${MNT_EXE_FLAGS} CACHE STRING
"Flags used for linking binaries during maintainer builds."
FORCE )
set( CMAKE_SHARED_LINKER_FLAGS_MAINTAINER
${MNT_SHRD_FLAGS} CACHE STRING
"Flags used by the shared libraries linker during maintainer builds."
FORCE )
mark_as_advanced(
CMAKE_CXX_FLAGS_MAINTAINER
CMAKE_C_FLAGS_MAINTAINER
CMAKE_EXE_LINKER_FLAGS_MAINTAINER
CMAKE_SHARED_LINKER_FLAGS_MAINTAINER )
# Update the documentation string of CMAKE_BUILD_TYPE for GUIs
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Debug")
endif()
set(CMAKE_BUILD_TYPE "${CMAKE_BUILD_TYPE}" CACHE STRING
"Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel Maintainer."
FORCE)
set(DISTRIBUTION_DIRECTORY "${CMAKE_BINARY_DIR}/${CMAKE_BUILD_TYPE}/Dist")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${BINARY_DIR}")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${LIBRARY_DIR}")
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${ARCHIVE_DIR}")
if(USE_MESA)
message(STATUS "GLSL compiler: mesa")
add_definitions(-DUSE_MESA)
add_subdirectory(mesa-glsl)
else()
message(STATUS "GLSL compiler: native")
add_subdirectory(GLSLCompiler)
endif()
add_subdirectory(glsldb)
if(GLSLDB_WIN)
add_subdirectory(3rdparty/mhook)
endif()