-
Notifications
You must be signed in to change notification settings - Fork 10
/
CMakeLists.txt
60 lines (52 loc) · 1.97 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
CMAKE_MINIMUM_REQUIRED(VERSION 3.1 FATAL_ERROR)
PROJECT(hacklib_project)
# set the default configuration to debug
IF(NOT CMAKE_BUILD_TYPE)
SET(CMAKE_BUILD_TYPE Debug)
ENDIF()
SET(PROJ_ROOT "${CMAKE_CURRENT_SOURCE_DIR}")
IF(CMAKE_SIZEOF_VOID_P EQUAL 8)
SET(ARCH_64BIT TRUE)
ADD_DEFINITIONS(-DARCH_64BIT)
SET(PROJ_BIN ${PROJ_ROOT}/bin64)
SET(PROJ_LIB ${PROJ_ROOT}/lib64)
ELSE()
SET(PROJ_BIN ${PROJ_ROOT}/bin)
SET(PROJ_LIB ${PROJ_ROOT}/lib)
ENDIF()
# default output directories
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJ_BIN})
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${PROJ_BIN})
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${PROJ_BIN})
SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJ_BIN})
SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG ${PROJ_BIN})
SET(CAMKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE ${PROJ_BIN})
SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJ_LIB})
SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG ${PROJ_LIB})
SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE ${PROJ_LIB})
IF(WIN32)
LINK_DIRECTORIES(${PROJ_LIB})
INCLUDE_DIRECTORIES(${PROJ_ROOT}/include)
ENDIF()
# global configuration
SET_PROPERTY(GLOBAL PROPERTY USE_FOLDERS ON)
SET(CMAKE_POSITION_INDEPENDENT_CODE ON)
SET(CMAKE_DEBUG_POSTFIX "d")
SET(CMAKE_CXX_STANDARD 14)
SET(CMAKE_CXX_STANDARD_REQUIRED ON)
IF(WIN32)
ADD_DEFINITIONS(/MP) # parallel compilation
ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS) # microsofts useless warnings
ADD_DEFINITIONS(-D_SCL_SECURE_NO_WARNINGS) # microsofts useless warnings
ADD_DEFINITIONS(-DNOMINMAX) # microsofts wonderful macros for min and max
ELSEIF(UNIX)
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_DEBUG")
SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -D_DEBUG")
ENDIF()
# projects
FILE(GLOB subdirs RELATIVE ${PROJ_ROOT} ${PROJ_ROOT}/src/*)
FOREACH(subdir ${subdirs})
IF(IS_DIRECTORY ${PROJ_ROOT}/${subdir})
ADD_SUBDIRECTORY(${PROJ_ROOT}/${subdir})
ENDIF()
ENDFOREACH()