-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathCMakeLists.txt
94 lines (73 loc) · 2.88 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
cmake_minimum_required(VERSION 3.24)
project(Vipster VERSION 1.20.0)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
include(CMakeDependentOption)
#################
# CMake Options #
#################
# CMAKE_BUILD_TYPE - default to optimized Release build
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING
"Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel ..."
FORCE)
endif()
# VIPSTER_DOWNLOAD_DEPENDENCIES - default to ON
# Disable this to enforce using already-installed dependencies.
# Intended for package maintainers only
option(VIPSTER_DOWNLOAD_DEPENDENCIES "Automatically download dependencies" ON)
mark_as_advanced(VIPSTER_DOWNLOAD_DEPENDENCIES)
# BUILD_TESTING - default to ON
option(BUILD_TESTING "Build tests" ON)
# BUILD_SHARED_LIBS - default to ON when not building for web
if(EMSCRIPTEN)
# not supported with emscripten, hide warnings
option(BUILD_SHARED_LIBS "Build shared library" OFF)
else()
option(BUILD_SHARED_LIBS "Build shared library" ON)
endif()
# VIPSTER_PYLIB - add python bindings for library, default to OFF
find_package(Python 3.7 QUIET COMPONENTS Interpreter Development)
cmake_dependent_option(VIPSTER_PYLIB "Standalone Python library" OFF ${Python_FOUND} OFF)
# VIPSTER_DESKTOP - add Qt-GUI target, default to ON if Qt available
find_package(Qt6 CONFIG QUIET COMPONENTS Widgets Gui OpenGLWidgets)
if(NOT ${Qt6_FOUND})
find_package(Qt5 5.10 CONFIG QUIET COMPONENTS Widgets Gui)
endif()
set(tmp ${VIPSTER_DESKTOP})
cmake_dependent_option(VIPSTER_DESKTOP "Build QT-based desktop app" ON "Qt6_FOUND OR Qt5_FOUND" OFF)
if(tmp AND NOT ${VIPSTER_DESKTOP})
# ensure GUI is not silently disabled
message(FATAL_ERROR "Requested to build the GUI, but no Qt installation was detected")
endif()
# VIPSTER_PYWIDGET - optional python widget for Qt GUI, default to ON if possible
cmake_dependent_option(VIPSTER_PYWIDGET "Python shell in desktop app" ${Python_FOUND} "VIPSTER_DESKTOP" OFF)
# VIPSTER_LAMMPS - optional widget for interactive simulations, default to OFF
cmake_dependent_option(VIPSTER_LAMMPS "Interactive LAMMPS in desktop app" OFF "VIPSTER_DESKTOP" OFF)
# VIPSTER_WEB - minimal render widget for embedding in browser applications
cmake_dependent_option(VIPSTER_WEB "Build JS+WebGL GUI" ON "EMSCRIPTEN" OFF)
#################
# Build targets #
#################
# dependencies
include(util/dependencies.cmake)
# libvipster, core component that everything else depends on
add_subdirectory(vipster)
# Python bindings
if(VIPSTER_PYLIB OR VIPSTER_PYWIDGET)
add_subdirectory(python)
endif()
# Full-featured Qt-based GUI
if(VIPSTER_DESKTOP)
add_subdirectory(gui/qt)
endif()
# standalone browser widget
if(VIPSTER_WEB)
add_subdirectory(gui/web)
endif()
# tests
if(BUILD_TESTING)
enable_testing()
add_subdirectory(tests)
endif()