-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
66 lines (54 loc) · 2.72 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
cmake_minimum_required(VERSION 3.0 FATAL_ERROR)
project(SandSim VERSION 1.1)
set(SFML_STATIC_LIBRARIES TRUE)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SUBSYSTEM:WINDOWS /ENTRY:mainCRTStartup")
file(GLOB_RECURSE SOURCE_FILES ${CMAKE_SOURCE_DIR}/src/*.cpp)
file(GLOB_RECURSE HEADER_FILES ${CMAKE_SOURCE_DIR}/src/*.h ${CMAKE_SOURCE_DIR}/src/*.hpp)
file(GLOB_RECURSE IMAGES_FILES ${CMAKE_SOURCE_DIR}/images/*)
FILE(COPY "${CMAKE_CURRENT_SOURCE_DIR}/images" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}")
add_executable(${PROJECT_NAME} ${SOURCE_FILES} ${HEADER_FILES})
find_package(SFML REQUIRED graphics)
target_link_libraries(${PROJECT_NAME} sfml-graphics)
install(TARGETS SandSim DESTINATION bin)
install(FILES ${IMAGES_FILES} DESTINATION images)
option(BUILD_DOC "Build documentation" ON)
if(BUILD_DOC)
find_package(Doxygen)
if (DOXYGEN_FOUND)
set(DOXYGEN_CONFIG_FILE ${CMAKE_SOURCE_DIR}/Doxyfile)
MACRO(CONFIGURE_DOXYGEN_FILE DOXYGEN_CONFIG_FILE FILE_NAME_SUFFIX)
IF(EXISTS ${PROJECT_SOURCE_DIR}/${DOXYGEN_CONFIG_FILE})
FILE(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/doxy-${FILE_NAME_SUFFIX}.conf)
FILE(READ ${PROJECT_SOURCE_DIR}/${DOXYGEN_CONFIG_FILE} DOXYFILE_CONTENTS)
STRING(REGEX REPLACE ";" "\\\\;" DOXYFILE_CONTENTS "${DOXYFILE_CONTENTS}")
STRING(REGEX REPLACE "\n" ";" DOXYFILE_LINES "${DOXYFILE_CONTENTS}")
LIST(LENGTH DOXYFILE_LINES ROW)
MATH(EXPR ROW "${ROW} - 1")
FOREACH(I RANGE ${ROW})
LIST(GET DOXYFILE_LINES ${I} LINE)
IF(LINE STRGREATER "")
STRING(REGEX MATCH "^[a-zA-Z]([^ ])+" DOXY_PARAM ${LINE})
IF(DEFINED DOXY_${DOXY_PARAM})
STRING(REGEX REPLACE "=([^\n])+" "= ${DOXY_${DOXY_PARAM}}" LINE ${LINE})
ENDIF(DEFINED DOXY_${DOXY_PARAM})
ENDIF()
FILE(APPEND ${CMAKE_CURRENT_BINARY_DIR}/doxy-${FILE_NAME_SUFFIX}.conf "${LINE}\n")
ENDFOREACH()
ELSE()
MESSAGE(SEND_ERROR "Doxygen configuration file '${DOXYGEN_CONFIG_FILE}' not found. Documentation will not be generated")
ENDIF()
ENDMACRO(CONFIGURE_DOXYGEN_FILE)
MACRO(ADD_DOCUMENTATION TARGET DOXYGEN_CONFIG_FILE)
CONFIGURE_DOXYGEN_FILE(${DOXYGEN_CONFIG_FILE} ${TARGET})
add_custom_target(${TARGET} ALL COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/doxy-${TARGET}.conf WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} VERBATIM)
ENDMACRO(ADD_DOCUMENTATION)
SET(DOXY_PROJECT_NAME ${PROJECT_NAME})
SET(DOXY_PROJECT_NUMBER ${PROJECT_VERSION})
SET(DOXY_INPUT ${CMAKE_SOURCE_DIR}/src)
SET(DOXY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
ADD_DOCUMENTATION(doc Doxyfile)
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html DESTINATION docs)
else(DOXYGEN_FOUND)
message("Doxygen need to be installed to generate the doxygen documentation")
endif(DOXYGEN_FOUND)
endif(BUILD_DOC)