Tidied the CMakeLists, moved stuff to more logical places and added comments. Also tested that ALTER_CONF=ON still works
This commit is contained in:
@@ -10,26 +10,22 @@
|
|||||||
# Print all options: cmake -LAH ..
|
# Print all options: cmake -LAH ..
|
||||||
#
|
#
|
||||||
|
|
||||||
|
|
||||||
## CMake settings
|
## CMake settings
|
||||||
cmake_minimum_required (VERSION 3.5.1) # Need >= 3.8 for first-class CUDA support
|
cmake_minimum_required (VERSION 3.5.1) # Need >= 3.8 for first-class CUDA support
|
||||||
|
|
||||||
## Project settings
|
## Project settings
|
||||||
project(astaroth C CXX)
|
project(astaroth C CXX)
|
||||||
set(CMAKE_CXX_STANDARD 11)
|
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
||||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR})
|
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR})
|
||||||
|
|
||||||
## Options
|
## Options
|
||||||
option(BUILD_DEBUG "Builds the program with extensive error checking" OFF)
|
option(BUILD_DEBUG "Builds the program with extensive error checking" OFF)
|
||||||
option(BUILD_STANDALONE "Builds the standalone Astaroth" ON)
|
option(BUILD_STANDALONE "Builds the standalone Astaroth" ON)
|
||||||
option(BUILD_RT_VISUALIZATION "Builds the module for real-time visualization using SDL2" OFF)
|
option(BUILD_RT_VISUALIZATION "Builds the module for real-time visualization using SDL2" OFF)
|
||||||
|
option(BUILD_C_API_TEST "Builds a C program to test whether the API is conformant" ON)
|
||||||
option(DOUBLE_PRECISION "Generates double precision code" OFF)
|
option(DOUBLE_PRECISION "Generates double precision code" OFF)
|
||||||
option(MULTIGPU_ENABLED "If enabled, uses all the available GPUs" ON)
|
option(MULTIGPU_ENABLED "If enabled, uses all the available GPUs" ON)
|
||||||
option(ALTER_CONF "If enabled, loads astaroth.conf from the build directory" OFF)
|
option(ALTER_CONF "If enabled, loads astaroth.conf from the build directory" OFF)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Build types
|
## Build types
|
||||||
# Available types (case-sensitive):
|
# Available types (case-sensitive):
|
||||||
# RELEASE (best performance)
|
# RELEASE (best performance)
|
||||||
@@ -41,27 +37,24 @@ else ()
|
|||||||
endif()
|
endif()
|
||||||
message(STATUS "Build type: " ${CMAKE_BUILD_TYPE})
|
message(STATUS "Build type: " ${CMAKE_BUILD_TYPE})
|
||||||
|
|
||||||
|
|
||||||
## Defines
|
## Defines
|
||||||
if (DOUBLE_PRECISION)
|
if (DOUBLE_PRECISION)
|
||||||
add_definitions(-DAC_DOUBLE_PRECISION=1)
|
add_definitions(-DAC_DOUBLE_PRECISION=1)
|
||||||
else ()
|
else ()
|
||||||
add_definitions(-DAC_DOUBLE_PRECISION=0)
|
add_definitions(-DAC_DOUBLE_PRECISION=0)
|
||||||
endif ()
|
endif ()
|
||||||
if (MULTIGPU_ENABLED)
|
|
||||||
add_definitions(-DAC_MULTIGPU_ENABLED=1)
|
|
||||||
else ()
|
|
||||||
add_definitions(-DAC_MULTIGPU_ENABLED=0)
|
|
||||||
endif ()
|
|
||||||
|
|
||||||
## Include directories
|
## Include directories
|
||||||
include_directories(.)
|
include_directories(.)
|
||||||
include_directories(include)
|
include_directories(include)
|
||||||
|
|
||||||
## Subdirectories
|
## Subdirectories
|
||||||
add_subdirectory(src/core)
|
add_subdirectory(src/core) # The core library
|
||||||
|
|
||||||
if (BUILD_STANDALONE)
|
if (BUILD_STANDALONE)
|
||||||
add_subdirectory(src/standalone)
|
add_subdirectory(src/standalone)
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
|
if (BUILD_C_API_TEST)
|
||||||
add_subdirectory(src/ctest)
|
add_subdirectory(src/ctest)
|
||||||
|
endif ()
|
||||||
|
@@ -25,6 +25,13 @@ set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} ${CUDA_ARCH_FLAGS} ${CUDA_WARNING_FLAGS})
|
|||||||
set(CUDA_NVCC_FLAGS_RELEASE)
|
set(CUDA_NVCC_FLAGS_RELEASE)
|
||||||
set(CUDA_NVCC_FLAGS_DEBUG --device-debug --generate-line-info --ptxas-options=-v)
|
set(CUDA_NVCC_FLAGS_DEBUG --device-debug --generate-line-info --ptxas-options=-v)
|
||||||
|
|
||||||
|
## Definitions
|
||||||
|
if (MULTIGPU_ENABLED)
|
||||||
|
add_definitions(-DAC_MULTIGPU_ENABLED=1)
|
||||||
|
else ()
|
||||||
|
add_definitions(-DAC_MULTIGPU_ENABLED=0)
|
||||||
|
endif ()
|
||||||
|
|
||||||
## Create and link the library
|
## Create and link the library
|
||||||
include_directories(.)
|
include_directories(.)
|
||||||
cuda_add_library(astaroth_core STATIC astaroth.cu device.cu)
|
cuda_add_library(astaroth_core STATIC astaroth.cu device.cu)
|
||||||
|
@@ -1,2 +1,9 @@
|
|||||||
|
##############################################
|
||||||
|
## CMakeLists.txt for the C API test ##
|
||||||
|
##############################################
|
||||||
|
|
||||||
|
set(CMAKE_C_STANDARD 11)
|
||||||
|
set(CMAKE_C_STANDARD_REQUIRED ON)
|
||||||
|
|
||||||
add_executable(ctest main.c)
|
add_executable(ctest main.c)
|
||||||
target_link_libraries(ctest PRIVATE astaroth_core)
|
target_link_libraries(ctest PRIVATE astaroth_core)
|
||||||
|
1
src/ctest/README.txt
Normal file
1
src/ctest/README.txt
Normal file
@@ -0,0 +1 @@
|
|||||||
|
This directory is used to test whether the Astaroth API is compatible with C.
|
@@ -2,6 +2,9 @@
|
|||||||
## CMakeLists.txt for Astaroth Standalone ##
|
## CMakeLists.txt for Astaroth Standalone ##
|
||||||
##############################################
|
##############################################
|
||||||
|
|
||||||
|
set(CMAKE_CXX_STANDARD 11)
|
||||||
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
|
|
||||||
## Files
|
## Files
|
||||||
file (GLOB SOURCES "*.cc" "model/*.cc")
|
file (GLOB SOURCES "*.cc" "model/*.cc")
|
||||||
|
|
||||||
@@ -17,7 +20,6 @@ if (BUILD_RT_VISUALIZATION)
|
|||||||
link_directories(${SDL2_LIBRARY_DIR})
|
link_directories(${SDL2_LIBRARY_DIR})
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
|
|
||||||
## Compilation flags
|
## Compilation flags
|
||||||
add_compile_options(-march=native -pipe ${OpenMP_CXX_FLAGS})
|
add_compile_options(-march=native -pipe ${OpenMP_CXX_FLAGS})
|
||||||
add_compile_options(-Wall -Wextra -Werror -Wdouble-promotion -Wfloat-conversion)# -Wshadow)
|
add_compile_options(-Wall -Wextra -Werror -Wdouble-promotion -Wfloat-conversion)# -Wshadow)
|
||||||
|
Reference in New Issue
Block a user