-
Notifications
You must be signed in to change notification settings - Fork 2
/
CMakeLists.txt
92 lines (74 loc) · 3.19 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
project(es)
cmake_minimum_required(VERSION 2.8.3)
set(VERSION_SO "1")
set(VERSION_MAJOR "0")
set(VERSION_MINOR "2")
set(VERSION_PATCH "7")
set(VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}")
set(CPACK_PACKAGE_NAME "lib${CMAKE_PROJECT_NAME}${VERSION_SO}")
set(WEBPAGE "http://github.com/Nocte-/es")
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build (Debug or Release)" FORCE)
endif()
set(BUILD_UNITTESTS 0 CACHE BOOL "Build the unit tests")
set(BUILD_DOCUMENTATION 0 CACHE BOOL "Generate Doxygen documentation")
# Set up the compiler
#
if(MSVC)
add_definitions(/D_WIN32_WINNT=0x0501 /D_CRT_SECURE_NO_WARNINGS /DSFML_STATIC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP /EHsc /wd4244 /wd4996 ")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /DNDEBUG /MT /MP /GS- /Ox /Ob2 /Oi /Oy /arch:SSE /fp:fast /Zi")
set(CMAKE_LIB_LINKER_FLAGS "${CMAKE_LIB_LINKER_FLAGS} /OPT:REF /SUBSYSTEM:WINDOWS")
else() # Most likely gcc or clang
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
elseif ("${CMAKE_CXX_COMPILER_VERSION}" VERSION_LESS "4.7")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -Wall")
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG")
set(CMAKE_CXX_FLAGS_DEBUG "-g")
set(CMAKE_LIB_LINKER_FLAGS "-s")
endif()
add_subdirectory(es)
if(BUILD_UNITTESTS)
add_subdirectory(unit_tests)
endif()
# Doxygen documentation
#
if(BUILD_DOCUMENTATION)
find_package(Doxygen)
if (DOXYGEN_FOUND STREQUAL "YES")
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile)
add_custom_target(doxygen ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile)
set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES api-doc)
get_target_property(DOC_TARGET doc TYPE)
if (NOT DOC_TARGET)
add_custom_target(doc)
endif()
add_dependencies(doc doxygen)
endif()
endif()
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Fast C++ entity system library")
set(CPACK_PACKAGE_VENDOR "Nocte")
set(CPACK_PACKAGE_CONTACT "Nocte <[email protected]>")
set(CPACK_SOURCE_IGNORE_FILES "CMakefiles;Makefile;CMakeCache.txt;_CPack_Packages;/.git/;.gitignore;.travis.yml")
set(CPACK_SOURCE_GENERATOR "TGZ")
set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}_${VERSION}")
if(UNIX)
set(CPACK_GENERATOR "DEB")
add_custom_target(dist COMMAND ${CMAKE_MAKE_PROGRAM} package_source)
set(PKGCONFIG_FILE ${CMAKE_CURRENT_SOURCE_DIR}/install/es.pc)
configure_file(${PKGCONFIG_FILE}.in ${PKGCONFIG_FILE})
install(FILES ${PKGCONFIG_FILE} DESTINATION ${CMAKE_INSTALL_PREFIX}/share/pkgconfig)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/install/FindES.cmake DESTINATION ${CMAKE_INSTALL_PREFIX}/share/cmake/Modules)
set(CPACK_DEBIAN_PACKAGE_SECTION "devel")
add_custom_target(deb dpkg-buildpackage)
add_dependencies(deb dist)
elseif(WIN32)
set(CPACK_GENERATOR "ZIP")
endif()
include(CPack)