-
Notifications
You must be signed in to change notification settings - Fork 4
/
CMakeLists.txt
45 lines (33 loc) · 1.97 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
cmake_minimum_required(VERSION 3.1)
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR})
# Name the project
project(ncvis
VERSION 0.1
LANGUAGES CXX
)
# Set some standard settings
set (CMAKE_CXX_STANDARD 11 CACHE STRING "The C++ standard to use")
set (CMAKE_CXX_STANDARD_REQUIRED ON)
set (CMAKE_CXX_EXTENSIONS OFF)
set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
set (CMAKE_SHARED_LINKER_FLAGS "-Wl,--as-needed")
set (CMAKE_GNU_FLAGS "-fpermissive")
# Find wxWidgets libraries
find_package(wxWidgets REQUIRED gl core base OPTIONAL_COMPONENTS net)
include(${wxWidgets_USE_FILE})
# Configure with NetCDF_ROOT=$PATH_TO_NETCDF_INSTALL
find_package(NetCDF REQUIRED)
find_program(NCCONFIG_EXE NAMES nc-config PATHS ${NETCDF_DIR}/bin ${NetCDF_ROOT}/bin)
# Get all necessary config flags
execute_process(COMMAND "${wxWidgets_CONFIG_EXECUTABLE}" "--cxxflags" OUTPUT_VARIABLE WX_COMPILE_FLAGS OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(COMMAND "${wxWidgets_CONFIG_EXECUTABLE}" "--prefix" OUTPUT_VARIABLE WXCONFIG_RPATH OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(COMMAND "${wxWidgets_CONFIG_EXECUTABLE}" "--libs" OUTPUT_VARIABLE WX_LINK_FLAGS OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(COMMAND "${NCCONFIG_EXE}" "--cflags" OUTPUT_VARIABLE NC_COMPILE_FLAGS OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(COMMAND "${NCCONFIG_EXE}" "--includedir" OUTPUT_VARIABLE NC_INCLUDE_DIR OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(COMMAND "${NCCONFIG_EXE}" "--libdir" OUTPUT_VARIABLE NC_LIB_DIR OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(COMMAND "${NCCONFIG_EXE}" "--libs" "--static" OUTPUT_VARIABLE NC_LINK_FLAGS OUTPUT_STRIP_TRAILING_WHITESPACE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_GNU_FLAGS} ${WX_COMPILE_FLAGS} ${NC_COMPILE_FLAGS} -I${NC_INCLUDE_DIR}")
set(NCVIS_LINKER_FLAGS "${WX_LINK_FLAGS} -L${NC_LIB_DIR} -lnetcdf ${NC_LINK_FLAGS}")
set (CMAKE_SHARED_LINKER_FLAGS "-Wl,--as-needed ")
set (CMAKE_EXE_LINKER_FLAGS "-Wl,-rpath,${WXCONFIG_RPATH}/lib")
add_subdirectory("src")