-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
121 lines (103 loc) · 4.08 KB
/
CMakeLists.txt
File metadata and controls
121 lines (103 loc) · 4.08 KB
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
cmake_minimum_required(VERSION 3.22) #present from, e.g., ubuntu 22.04 on
project(openQmin VERSION 0.11
DESCRIPTION "Landau de Gennes liquid crystal modeling, with or without cuda"
LANGUAGES CXX)
#generate compile commands for clangd
set(CMAKE_EXPORT_COMPILE_COMMANDS 1)
add_definitions(-DDIMENSION=5)
add_definitions(-DDIRECTORY="${CMAKE_CURRENT_SOURCE_DIR}")
#set a default "Release" build type
set(default_build_type "Release")
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "Setting build type to '${default_build_type}' as none was specified.")
set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE
STRING "Choose the type of build." FORCE)
# Set the possible values of build type for cmake-gui
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
"Debug" "Release" "MinSizeRel" "RelWithDebInfo")
endif()
#Set c++ standard and various compilation flags
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wshadow -Wno-unused-function -Wno-deprecated-copy -Wno-sign-compare -Wno-unused-parameter -Wno-unused-variable -Wno-unknown-pragmas -Wno-class-memaccess -Wno-shadow -Wno-return-type -Wno-reorder")
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
if(${CMAKE_BUILD_TYPE} MATCHES "Debug")
message(STATUS "Compiling with debugging symbols")
add_definitions(-DDEBUGFLAGUP)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O0")
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -g -lineinfo -Xptxas --generate-line-info")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -march=native")
endif()
#Handle initial stuff if we're building the gui
if(DEFINED ENABLE_QT)
# list(APPEND CMAKE_PREFIX_PATH /home/daniel/Qt/6.8.1/gcc_64)
##Add hint here
find_package(Qt6 REQUIRED COMPONENTS OpenGLWidgets Widgets Core Gui)
find_package(OpenGL REQUIRED)
qt_standard_project_setup()
set(CMAKE_INCLUDE_CURRENT_DIR ON)
else()
message(STATUS "Disabling QT compilation")
endif()
# Check if the user has disabled cuda support
#If not, look for on the system and, if it is present, set a project-wide variable
# https://cliutils.gitlab.io/modern-cmake/chapters/packages/CUDA.html
if(DEFINED DISABLE_CUDA)
message(STATUS "Disabling cuda compilation")
else()
include(CheckLanguage)
check_language(CUDA)
if(CMAKE_CUDA_COMPILER)
message(STATUS "CUDA found, building with GPU support")
add_definitions(-DENABLE_CUDA)
enable_language(CUDA)
include_directories(${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES})
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -diag-suppress 20040 -diag-suppress 20015 -diag-suppress 20013")
set(CMAKE_CUDA_ARCHITECTURES "50;52;70")
message(STATUS "setting cuda compilation of gpuarray file")
else()
message(STATUS "CUDA not found, building without GPU support")
endif()
endif()
if(CMAKE_CUDA_COMPILER)
# message("cuda directories ${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES}")
set_source_files_properties(src/utilities/gpuarray.cpp PROPERTIES LANGUAGE CUDA)
endif()
#set the list of libraries defined and built in all of the subdirectories of src/
set(myLibraries
dataTypesAndContainersLibrary
utilities forces models simulations updaters
)
if(CMAKE_CUDA_COMPILER)
list(APPEND myLibraries utilitiesGPU modelsGPU forcesGPU updatersGPU)
endif()
find_package(MPI REQUIRED)
include_directories(
inc
src/model src/forces src/simulation src/updaters src/utilities
# ${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES}
${MPI_INCLUDE_PATH}
)
add_subdirectory(src)
message(STATUS "${myLibraries}")
add_executable(${PROJECT_NAME}
openQmin.cpp
)
target_link_libraries(${PROJECT_NAME} PUBLIC ${myLibraries} MPI::MPI_CXX)
if(ENABLE_QT)
qt_add_executable(guiOpenQMin
openQminGUI.cpp mainwindow.cpp oglwidget.cpp
mainwindow.ui
)
target_include_directories(guiOpenQMin PRIVATE
/usr/include/GL
)
target_link_libraries(guiOpenQMin PUBLIC ${myLibraries}
Qt6::Widgets
Qt6::Core
Qt6::OpenGLWidgets
Qt6::Gui
${OPENGL_LIBRARY}
MPI::MPI_CXX
)
endif()