diff --git a/CMakeLists.txt b/CMakeLists.txt index a59d256..a82620a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,26 +10,22 @@ # Print all options: cmake -LAH .. # - ## CMake settings cmake_minimum_required (VERSION 3.5.1) # Need >= 3.8 for first-class CUDA support ## Project settings project(astaroth C CXX) -set(CMAKE_CXX_STANDARD 11) -set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}) ## Options option(BUILD_DEBUG "Builds the program with extensive error checking" OFF) option(BUILD_STANDALONE "Builds the standalone Astaroth" ON) 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(MULTIGPU_ENABLED "If enabled, uses all the available GPUs" ON) option(ALTER_CONF "If enabled, loads astaroth.conf from the build directory" OFF) - - ## Build types # Available types (case-sensitive): # RELEASE (best performance) @@ -41,27 +37,24 @@ else () endif() message(STATUS "Build type: " ${CMAKE_BUILD_TYPE}) - ## Defines if (DOUBLE_PRECISION) add_definitions(-DAC_DOUBLE_PRECISION=1) else () add_definitions(-DAC_DOUBLE_PRECISION=0) 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) ## Subdirectories -add_subdirectory(src/core) +add_subdirectory(src/core) # The core library + if (BUILD_STANDALONE) add_subdirectory(src/standalone) endif () -add_subdirectory(src/ctest) +if (BUILD_C_API_TEST) + add_subdirectory(src/ctest) +endif () diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index e70de80..5cbc271 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -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_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 include_directories(.) cuda_add_library(astaroth_core STATIC astaroth.cu device.cu) diff --git a/src/ctest/CMakeLists.txt b/src/ctest/CMakeLists.txt index 393d7b6..f3439f3 100644 --- a/src/ctest/CMakeLists.txt +++ b/src/ctest/CMakeLists.txt @@ -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) target_link_libraries(ctest PRIVATE astaroth_core) diff --git a/src/ctest/README.txt b/src/ctest/README.txt new file mode 100644 index 0000000..68750d2 --- /dev/null +++ b/src/ctest/README.txt @@ -0,0 +1 @@ +This directory is used to test whether the Astaroth API is compatible with C. diff --git a/src/standalone/CMakeLists.txt b/src/standalone/CMakeLists.txt index 9ca17e5..b444800 100644 --- a/src/standalone/CMakeLists.txt +++ b/src/standalone/CMakeLists.txt @@ -2,6 +2,9 @@ ## CMakeLists.txt for Astaroth Standalone ## ############################################## +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + ## Files file (GLOB SOURCES "*.cc" "model/*.cc") @@ -17,7 +20,6 @@ if (BUILD_RT_VISUALIZATION) link_directories(${SDL2_LIBRARY_DIR}) endif () - ## Compilation flags add_compile_options(-march=native -pipe ${OpenMP_CXX_FLAGS}) add_compile_options(-Wall -Wextra -Werror -Wdouble-promotion -Wfloat-conversion)# -Wshadow)