forked from joddlehod/dnad
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
35 lines (26 loc) · 1.13 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
cmake_minimum_required(VERSION 3.0)
project(DNAD Fortran)
set(IS_NOT_SUBDIRECTORY ${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR})
# If built as a subdirectory, we don't want to do any testing,
# because testing forces a specific number of derivatives
if (${IS_NOT_SUBDIRECTORY})
set (DNAD_NDERIV 4 CACHE STRING "Number of Independent Variables" FORCE)
else()
set (DNAD_NDERIV 0 CACHE STRING "Number of Independent Variables")
endif()
if (${DNAD_NDERIV} EQUAL 0)
message(FATAL_ERROR "Please set DNAD_NDERIV to integer value")
endif()
configure_file(src/dnad_nderiv.f90.in dnad_nderiv.f90)
add_library(dnad STATIC src/dnad.f90 dnad_nderiv.f90)
add_library(DNAD::dnad ALIAS dnad)
if (${IS_NOT_SUBDIRECTORY})
enable_testing()
target_compile_options(dnad PUBLIC -coverage)
target_link_options(dnad PUBLIC -coverage -lgcov)
add_executable(unittests test/unittests.f90)
target_link_libraries(unittests dnad)
add_test(NAME unittests_test
COMMAND $<TARGET_FILE:unittests> ${CMAKE_CURRENT_BINARY_DIR}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
endif()