-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
129 lines (112 loc) · 3.53 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
121
122
123
124
125
126
127
128
129
cmake_minimum_required(VERSION 3.21)
project(Evolving-Plants VERSION 4.1 LANGUAGES CXX)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
find_package(QT NAMES Qt6 COMPONENTS Widgets REQUIRED)
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Widgets REQUIRED)
configure_file(BuildVersion.h.in ${PROJECT_SOURCE_DIR}/BuildVersion.h)
set(PROJECT_SOURCES
BuildVersion.h
Gene.h
GeneFactory.h
GeneFactory.cpp
GeneLeafColour.h
GeneLeafColour.cpp
GenePlantStructure.h
GenePlantStructure.cpp
GeneSeedProduction.h
GeneSeedProduction.cpp
LightMap.h
LightMap.cpp
main.cpp
MainWindow.h
MainWindow.cpp
MainWindow.ui
Phenotype.h
Phenotype.cpp
Plant.h
Plant.cpp
Resources.qrc
SavedGenomes.qrc
Simulation.h
Simulation.cpp
SimulationInfoTableModel.h
SimulationInfoTableModel.cpp
SimulationViewWidget.h
SimulationViewWidget.cpp
)
if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
qt_add_executable(Evolving-Plants
MANUAL_FINALIZATION
${PROJECT_SOURCES}
)
# Define target properties for Android with Qt 6 as:
# set_property(TARGET Evolving-Plants APPEND PROPERTY QT_ANDROID_PACKAGE_SOURCE_DIR
# ${CMAKE_CURRENT_SOURCE_DIR}/android)
# For more information, see https://doc.qt.io/qt-6/qt-add-executable.html#target-creation
else()
if(ANDROID)
add_library(Evolving-Plants SHARED
${PROJECT_SOURCES}
)
# Define properties for Android with Qt 5 after find_package() calls as:
# set(ANDROID_PACKAGE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/android")
else()
add_executable(Evolving-Plants
${PROJECT_SOURCES}
)
endif()
endif()
include(FetchContent)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR})
include(json)
include(fmt)
include(utility)
target_link_libraries(Evolving-Plants
PRIVATE
Qt6::Widgets
nlohmann_json::nlohmann_json
fmt::fmt
Utility
)
# Make additional files appear in QtCreator
FILE(GLOB SAVD_GENOMES SavedGenomes/*)
add_custom_target(Other
SOURCES
README.md
${SAVD_GENOMES}
${JAVA_CODE}
)
set_target_properties(Evolving-Plants PROPERTIES
MACOSX_BUNDLE_GUI_IDENTIFIER my.example.com
MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
MACOSX_BUNDLE TRUE
WIN32_EXECUTABLE TRUE
)
if(QT_VERSION_MAJOR EQUAL 6)
qt_finalize_executable(Evolving-Plants)
endif()
# Ensure our release contains our saved genomes
add_custom_command(TARGET Evolving-Plants POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/SavedGenomes/ ${CMAKE_BINARY_DIR}/SavedGenomes/
COMMENT "Copying SharedGenomes directory..."
)
# Make deploying/distributing this executable much easier!
if (WIN32)
# Retrieve the absolute path to qmake and then use that path to find
# the windeployqt and qtenv2 executables
get_target_property(QMAKE_EXE Qt6::qmake IMPORTED_LOCATION)
get_filename_component(QT_BIN_DIR "${QMAKE_EXE}" DIRECTORY)
find_program(WINDEPLOYQT_ENV_SETUP qtenv2.bat HINTS "${QT_BIN_DIR}")
find_program(WINDEPLOYQT_EXECUTABLE windeployqt HINTS "${QT_BIN_DIR}")
add_custom_command(TARGET Evolving-Plants
POST_BUILD
COMMAND "${WINDEPLOYQT_ENV_SETUP}" && "${WINDEPLOYQT_EXECUTABLE}" \"$<TARGET_FILE:Evolving-Plants>\" --no-translations
COMMENT "Packaging dependancies..."
)
endif()