-
Notifications
You must be signed in to change notification settings - Fork 2
/
CMakeLists.txt
72 lines (58 loc) · 2.11 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
cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
project(Vriska CXX)
#Conf
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR)
message(WARNING "In-source builds are not encouraged. Make a separate folder for building:\nmkdir build; cd build; cmake ..; cd ..\nBefore that, remove the files already created:\nrm -rf CMakeCache.txt CMakeFiles")
endif()
if(VRISKA_LIBRARY_TYPE)
if ((NOT VRISKA_LIBRARY_TYPE STREQUAL "SHARED")
AND (NOT VRISKA_LIBRARY_TYPE STREQUAL "STATIC"))
message(FATAL_ERROR "Unknown type of build: ${VRISKA_LIBRARY_TYPE} [SHARED|STATIC]")
endif()
else()
set(VRISKA_LIBRARY_TYPE SHARED)
endif()
#/Conf
if (VRISKA_LIBRARY_TYPE STREQUAL "SHARED")
add_definitions(-DVRISKA_LIB_DYNAMIC)
else()
add_definitions(-DVRISKA_LIB_STATIC)
endif()
#Common vars
set(BUILD_FOLDER ${PROJECT_BINARY_DIR})
set(EXECUTABLE_OUTPUT_PATH "${BUILD_FOLDER}/bin")
set(LIBRARY_OUTPUT_PATH "${BUILD_FOLDER}/lib")
set(VRISKA_COMPILE_FLAGS "${CMAKE_CXX_FLAGS}")
if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
set(VRISKA_COMPILE_FLAGS "${VRISKA_COMPILE_FLAGS} -fvisibility=hidden")
endif()
if (CMAKE_BUILD_TYPE MATCHES "Debug")
if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
set(VRISKA_COMPILE_FLAGS "${VRISKA_COMPILE_FLAGS} -Wall -Wextra -Wshadow -Wundef")
elseif(MSVC)
set(VRISKA_COMPILE_FLAGS "${VRISKA_COMPILE_FLAGS} /wd4251")
endif()
endif()
if(APPLE)
set(CMAKE_SKIP_BUILD_RPATH FALSE)
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
set(CMAKE_INSTALL_RPATH "")
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH FALSE)
endif()
#/Common vars
set(VRISKA_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
set(VRISKA_LIBRARIES_DIRS ${PROJECT_BINARY_DIR}/lib)
include_directories(${VRISKA_INCLUDE_DIR})
add_subdirectory(Core)
add_subdirectory(Threads)
add_subdirectory(Network)
set(VRISKA_LIBRARIES
${VRISKA_CORE_LIB}
${VRISKA_THREAD_LIB}
${VRISKA_NETWORK_LIB})
if(VRISKA_BUILD_TESTS)
add_subdirectory(tests)
endif()
set(VRISKA_INCLUDE_DIR ${VRISKA_INCLUDE_DIR} PARENT_SCOPE)
set(VRISKA_LIBRARIES_DIRS ${VRISKA_LIBRARIES_DIRS} PARENT_SCOPE)
set(VRISKA_LIBRARIES ${VRISKA_LIBRARIES} PARENT_SCOPE)