From defa023dbc918c0b538a4e662d194ef2ab00db35 Mon Sep 17 00:00:00 2001 From: Thibault Hallouin <thibault.hallouin@inrae.fr> Date: Fri, 9 Dec 2022 16:07:22 +0100 Subject: [PATCH] tidy up CMake files --- CMakeLists.txt | 29 +++++++++++++++++++++++++---- tests/CMakeLists.txt | 13 +++++++++---- 2 files changed, 34 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 908440a..22712a3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,22 @@ cmake_minimum_required(VERSION 3.15) -project(EvalHyd LANGUAGES CXX VERSION 0.0.1 DESCRIPTION "Utility to evaluate streamflow predictions") + +project( + EvalHyd + LANGUAGES CXX + VERSION 0.0.1 + DESCRIPTION "Utility to evaluate streamflow predictions" +) + +# ------------------------------------------------------------------------------ +# dependencies +# ------------------------------------------------------------------------------ + +find_package(xtensor REQUIRED) +message(STATUS "Found xtensor: ${xtensor_INCLUDE_DIRS}/xtensor") + +# ------------------------------------------------------------------------------ +# build +# ------------------------------------------------------------------------------ # define evalhyd library add_library( @@ -22,8 +39,6 @@ target_include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/src ) -find_package(xtensor REQUIRED) - target_link_libraries( evalhyd PUBLIC @@ -36,9 +51,15 @@ target_compile_features( cxx_std_14 ) -# testing +# test suite OPTION(EVALHYD_BUILD_TEST "configure and compile tests" ON) if(EVALHYD_BUILD_TEST) add_subdirectory(tests) endif() + +# ------------------------------------------------------------------------------ +# installation +# ------------------------------------------------------------------------------ + +# TODO diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 48c1462..02690d4 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,6 +1,13 @@ cmake_minimum_required(VERSION 3.15) -# TEST SUITE ------------------------------------------------------------------- +# ------------------------------------------------------------------------------ +# dependencies +# ------------------------------------------------------------------------------ +find_package(GTest REQUIRED) + +# ------------------------------------------------------------------------------ +# build +# ------------------------------------------------------------------------------ add_executable( evalhyd_tests test_determinist.cpp @@ -17,11 +24,9 @@ target_include_directories( target_compile_definitions( evalhyd_tests PRIVATE - EVALHYD_DATA_DIR="${CMAKE_CURRENT_SOURCE_DIR}/data" + EVALHYD_DATA_DIR="${CMAKE_CURRENT_SOURCE_DIR}/data" ) -find_package(GTest REQUIRED) - target_link_libraries( evalhyd_tests PRIVATE -- GitLab