-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathCMakeLists.txt
153 lines (129 loc) · 4.53 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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
# CMakeLists.txt --- CMake project settings
# ex) cmake -G "Visual Studio 9 2008" .
# ex) cmake -DCMAKE_BUILD_TYPE=Release -G "MSYS Makefiles" .
##############################################################################
# CMake minimum version
cmake_minimum_required(VERSION 2.4)
# use new policy
if(COMMAND cmake_policy)
cmake_policy(SET CMP0054 NEW)
cmake_policy(SET CMP0003 NEW)
endif(COMMAND cmake_policy)
# project name and language
project(XScreenSaverWin C)
enable_language(CXX)
# check build type
if (NOT CMAKE_BUILD_TYPE)
message(STATUS "No build type selected, default to Debug")
set(CMAKE_BUILD_TYPE "Debug")
endif()
# make uppercase string of build type
string(TOUPPER "${CMAKE_BUILD_TYPE}" uppercase_CMAKE_BUILD_TYPE)
# check build type again
if (NOT uppercase_CMAKE_BUILD_TYPE MATCHES "^(DEBUG|RELEASE|RELWITHDEBINFO|MINSIZEREL)$")
message(FATAL_ERROR "Invalid value for CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}")
endif()
# set output directory (build/)
set(CMAKE_BINARY_DIR ${CMAKE_SOURCE_DIR}/build)
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR})
set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR})
# Win32 or not?
if (NOT WIN32)
message(FATAL_ERROR "You must use a Win32 compiler")
endif()
# do statically link
set(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
set(BUILD_SHARED_LIBRARIES OFF)
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
# using GCC
set(CMAKE_C_FLAGS "-static -static-libgcc -static-libstdc++")
set(CMAKE_CXX_FLAGS "-static -static-libgcc -static-libstdc++")
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
# using Clang
set(CMAKE_C_FLAGS "-static")
set(CMAKE_CXX_FLAGS "-static")
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
# replace "/MD" with "/MT" (building without runtime DLLs)
set(CompilerFlags
CMAKE_C_FLAGS
CMAKE_C_FLAGS_DEBUG
CMAKE_C_FLAGS_RELEASE
CMAKE_C_FLAGS_RELWITHDEBINFO
CMAKE_CXX_FLAGS
CMAKE_CXX_FLAGS_DEBUG
CMAKE_CXX_FLAGS_RELEASE
CMAKE_CXX_FLAGS_RELWITHDEBINFO)
foreach(CompilerFlags ${CompilerFlags})
string(REPLACE "/MD" "/MT" ${CompilerFlags} "${${CompilerFlags}}")
endforeach()
endif()
# enable Win32 resource
enable_language(RC)
##############################################################################
find_package(OpenGL)
# add_screensaver macro
macro(add_screensaver)
set(SOURCES "")
set(TARGET "")
foreach(argument ${ARGN})
if("${TARGET}" STREQUAL "")
set(TARGET ${argument})
else()
list(APPEND SOURCES ${argument})
endif()
endforeach()
add_executable(${TARGET} ${SOURCES})
set_target_properties(${TARGET} PROPERTIES SUFFIX ".scr")
target_link_libraries(${TARGET} comctl32 scrnsave)
endmacro()
# add_screenhack_screensaver macro
macro(add_screenhack_screensaver)
set(SOURCES "")
set(TARGET "")
foreach(argument ${ARGN})
if("${TARGET}" STREQUAL "")
set(TARGET ${argument})
else()
list(APPEND SOURCES ${argument})
endif()
endforeach()
add_executable(${TARGET} ${SOURCES} ../screenhack_res.rc)
set_target_properties(${TARGET} PROPERTIES SUFFIX ".scr")
target_link_libraries(${TARGET} comctl32 screenhack scrnsave)
endmacro()
# add_xlockmore_screensaver macro
macro(add_xlockmore_screensaver)
set(SOURCES "")
set(TARGET "")
foreach(argument ${ARGN})
if("${TARGET}" STREQUAL "")
set(TARGET ${argument})
else()
list(APPEND SOURCES ${argument})
endif()
endforeach()
add_executable(${TARGET} ${SOURCES} ../xlockmore_res.rc)
set_target_properties(${TARGET} PROPERTIES SUFFIX ".scr")
target_link_libraries(${TARGET} comctl32 xlockmore scrnsave)
endmacro()
##############################################################################
add_definitions(-DUSE_GL=1)
include_directories(. include gl-parts/include)
if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
# MSVC slowed down by many warnings
add_definitions(/W1)
else()
add_subdirectory(scrnsave)
endif()
add_subdirectory(debughelper)
add_subdirectory(gle)
add_subdirectory(gl-parts)
add_subdirectory(random)
add_subdirectory(xscreensaver)
add_subdirectory(xscreensaver-text)
add_subdirectory(common)
add_subdirectory(xlockmore)
add_subdirectory(screenhack)
add_subdirectory(nongl-savers)
add_subdirectory(gl-savers)
##############################################################################