-
Notifications
You must be signed in to change notification settings - Fork 9
/
CMakeLists.txt
120 lines (88 loc) · 4.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
########### ADD CAFLOOD application ###############
# Application that performs a 2D flood modelling using cellular
# automata model(s) and it is implemented using the CAAPI.
### Set up the application configuration
# The exe name of the app.
set(CAAPI_APP_EXE "caflood")
# The main source of the app.
set(CAAPI_APP_MAIN "main.cpp")
# The source of the app.
set(CAAPI_APP_SOURCES "")
file(GLOB CAAPI_APP_SOURCES "*.cpp")
# The headers of the app.
set(CAAPI_APP_HEADERS "")
file(GLOB CAAPI_APP_HEADERS "*.hpp")
# The data
set(CAAPI_APP_DATA "NEWS;LICENSE;AUTHORS;Version.txt;CMakeLists.txt")
# Find the CA functions
set(CAAPI_APP_CAFUNCTIONS)
set(CAAPI_IMPL_HEADERS)
# CAFUNCTIONS
CAAPI_add_source_dir(CAfunctions "${CMAKE_CURRENT_SOURCE_DIR}/*.ca" CAAPI_APP_CAFUNCTIONS)
# Execute the module that manage ca for the specific implementation
if(EXISTS "${CAAPI_SPECIFIC_IMPL_DIR}/extra/CAAPI_ca.cmake")
include("${CAAPI_SPECIFIC_IMPL_DIR}/extra/CAAPI_ca.cmake")
CAAPI_ca("${CAAPI_SPECIFIC_IMPL_DIR}" CAAPI_IMPL_HEADERS CAAPI_APP_CAFUNCTIONS)
endif()
# Set up the custom target name
set(CAAPI_APP_CUSTOM_TARGET "${CAAPI_APP_EXE}_do_impl_headers")
# Create the target that make the eventual implementation headers
# necessary.
add_custom_target(${CAAPI_APP_CUSTOM_TARGET} DEPENDS
${CAAPI_IMPL_HEADERS} ${CAAPI_HEADERS} ${CAAPI_APP_CAFUNCTIONS})
# Add the executable to the project using the specified source files.
add_executable("${CAAPI_APP_EXE}" "${CAAPI_APP_MAIN}"
${CAAPI_APP_SOURCES} ${CAAPI_SOURCES}
${CAAPI_APP_CAFUNCTIONS} ${CAAPI_HEADERS} ${CAAPI_APP_HEADERS})
add_dependencies("${CAAPI_APP_EXE}" ${CAAPI_APP_CUSTOM_TARGET})
target_link_libraries("${CAAPI_APP_EXE}" ${CAAPI_IMPL_LIBRARIES} )
########################## VERSION ##########################
file(STRINGS "Version.txt" CAAPI_APP_VERSION)
# Show the version number
message(STATUS "[${CAAPI_APP_NAME}]: Version ${CAAPI_APP_VERSION}")
if (WIN32)
add_definitions( /DCAAPI_APP_VERSION=${CAAPI_APP_VERSION} )
add_definitions( /DCAAPI_APP_NAME=${CAAPI_APP_NAME} )
else()
add_definitions( -DCAAPI_APP_VERSION=${CAAPI_APP_VERSION} )
add_definitions( -DCAAPI_APP_NAME=${CAAPI_APP_NAME} )
endif()
########################## INFO ##########################
# Number of files
list(LENGTH CAAPI_APP_CAFUNCTIONS __num_ca)
list(LENGTH CAAPI_APP_DATA __num_data)
list(LENGTH CAAPI_APP_HEADERS __num_headers)
list(LENGTH CAAPI_APP_SOURCES __num_sources)
MATH(EXPR __num_sources "${__num_sources}+1")
message(STATUS "[${CAAPI_APP_NAME}]: File #: Source (${__num_sources}) Headers (${__num_headers}) CA (${__num_ca}) Data (${__num_data})")
########################## INSTALL ##########################
# Set the component name which will influence the archive name.
set(CAAPI_APP_COMPONENT_NAME "app-${CAAPI_APP_NAME}-${CAAPI_APP_VERSION}")
# Add the file that are needed to compile this application into its
# specific component.
install(FILES
${CAAPI_APP_MAIN}
${CAAPI_APP_SOURCES}
${CAAPI_APP_HEADERS}
${CAAPI_APP_DATA}
${CAAPI_APP_CAFUNCTIONS}
DESTINATION apps/caflood
COMPONENT ${CAAPI_APP_COMPONENT_NAME})
# Set the component name which will influence the archive name for the binary file
set(CAAPI_BIN_COMPONENT_NAME "bin-${CAAPI_APP_NAME}-${CAAPI_APP_VERSION}")
# Install source code.
install(TARGETS ${CAAPI_APP_EXE}
DESTINATION bin/
COMPONENT ${CAAPI_BIN_COMPONENT_NAME})
########################## PACKAGE ##########################
# Add the newly created component
cpack_add_component(${CAAPI_APP_COMPONENT_NAME} DISPLAY_NAME "caflood version ${CAAPI_APP_VERSION}"
DESCRIPTION "Application that performs a 2D flood modelling using cellular
automata model(s) and it is implemented using the CAAPI"
GROUP apps)
# Add the newly created component
cpack_add_component(${CAAPI_BIN_COMPONENT_NAME} DISPLAY_NAME "Binary of caflood version ${CAAPI_APP_VERSION}"
DESCRIPTION "Binary of the application that performs a 2D
flood modelling using cellular automata model(s) and it is
implemented using the CAAPI."
GROUP apps)