-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathCMakeLists.txt
85 lines (64 loc) · 3.02 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
cmake_minimum_required(VERSION 3.0.2)
if ("${CMAKE_BUILD_TYPE}" STREQUAL "")
set(CMAKE_BUILD_TYPE "Debug")
endif()
if(APPLE)
set(CMAKE_CXX_COMPILER "/usr/bin/clang++")
set(CMAKE_C_COMPILER "/usr/bin/clang")
elseif(UNIX)
elseif(WIN32)
#set(SDL2_DIR ${CMAKE_CURRENT_SOURCE_DIR}/libs/sdl2)
set(SDL2_LIBRARY C:\\SDL\\SDL2\\lib)
set(SDL2_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}\\libs\\sdl2\\win\\include)
set(SDL2_IMAGE_LIBRARY C:\\SDL\\SDL2_image\\lib)
set(SDL2_IMAGE_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}\\libs\\sdl2\\win\\include)
endif()
set(LIBRARY_FOLDER ${CMAKE_CURRENT_SOURCE_DIR}/libs)
#-fprofile-instr-generate -fcoverage-mapping --coverage
if(APPLE)
set(BASE_FLAGS "${CMAKE_CXX_FLAGS} -Wno-reorder -Wno-inconsistent-missing-override -std=c++14 -stdlib=libc++ -fdiagnostics-show-option") # -Wall
elseif(UNIX)
set(BASE_FLAGS "${CMAKE_CXX_FLAGS} -Wno-reorder -Wno-inconsistent-missing-override -std=c++14 -stdlib=libstdc++ -fdiagnostics-show-option") # -Wall
elseif(WIN32)
add_compile_options(/wd4068) # unknown pragma
add_compile_options(/wd4244) # conversion from T to U, possible loss of data
add_compile_options(/wd4267) # conversion from T to U, possible loss of data
add_compile_options(/wd4996) # this function or variable may be unsafe
add_compile_options(/wd4390) # empty controlled statement found
add_compile_options(/wd4715) # not all control paths return a value
add_compile_options(/Zi)
#add_definitions(-DYAML_CPP_DLL)
endif()
if(!WIN32)
add_definitions(-DCMAKE_BUILD)
if (DEBUG_LEVEL)
add_definitions(-DDEBUG=${DEBUG_LEVEL})
endif()
endif()
#set(BASE_FLAGS "${BASE_FLAGS} -fno-rtti -fno-exceptions")
if (WIN32)
set(DEBUG_FLAGS "-DDEBUG:FULL")
else()
set(DEBUG_FLAGS "-O0 -g -fstandalone-debug")
endif()
set(CMAKE_CXX_FLAGS_DEBUG "${DEBUG_FLAGS} ${BASE_FLAGS}" CACHE FILEPATH "cache")
set(CMAKE_CXX_FLAGS_MINSIZEREL "-O3 -flto -DNDEBUG ${BASE_FLAGS}" CACHE FILEPATH "cache")
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -flto -DNDEBUG ${BASE_FLAGS}" CACHE FILEPATH "cache")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O3 -flto -g ${BASE_FLAGS}" CACHE FILEPATH "cache")
set(CMAKE_C_FLAGS_DEBUG "${DEBUG_FLAGS}" CACHE FILEPATH "cache")
set(CMAKE_C_FLAGS_MINSIZEREL "-Os -DNDEBUG" CACHE STRING "" FORCE)
set(CMAKE_C_FLAGS_RELEASE "-flto -O3 -DNDEBUG" CACHE STRING "" FORCE)
set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O3 -flto -g" CACHE STRING "" FORCE)
message("Build Type is ${CMAKE_BUILD_TYPE}")
message("Base flags are ${BASE_FLAGS}")
message("Debug flags are ${CMAKE_CXX_FLAGS_DEBUG}")
message("Release flags are ${CMAKE_CXX_FLAGS_RELEASE}")
message("CXX path is ${CMAKE_CXX_COMPILER}")
message("Libraries path is ${LIBRARY_FOLDER}")
#if("${PROJECT_SOURCE_DIR}" STREQUAL "${PROJECT_BINARY_DIR}")
# message(FATAL_ERROR "In-source builds are not permitted. Make a separate folder for building:\nmkdir build; cd build; cmake ..\nBefore that, remove the files already created:\nrm -rf CMakeCache.txt CMakeFiles")
#endif()
set(CMAKE_DISABLE_SOURCE_CHANGES ON)
set(CMAKE_DISABLE_IN_SOURCE_BUILD ON)
project("openmom" CXX C)
add_subdirectory(src)