Commit dbeb5478 authored by Damien L-G's avatar Damien L-G

Add GSL_EXTERNAL_PROJECT option and search for GSL if it is OFF

parent c9e3dbaa
......@@ -2,6 +2,10 @@ cmake_minimum_required(VERSION 3.10)
project(noname LANGUAGES CXX)
option(GSL_EXTERNAL_PROJECT "Whether to download and build the GNU Scientific Library (ON) or to search for it (OFF)" ON)
if(GSL_EXTERNAL_PROJECT)
include(ExternalProject)
ExternalProject_Add(project_gsl
......@@ -21,13 +25,25 @@ set_property(TARGET gsl PROPERTY IMPORTED_LOCATION ${install_dir}/lib/libgsl.a)
add_dependencies(gsl project_gsl)
else()
# NOTE FindGSL "official" CMake module explicitly select shared libraries so this might need adjustment
find_package(GSL 2.5 REQUIRED)
endif()
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED YES)
add_library(noname STATIC noname.cpp Map.cpp)
target_include_directories(noname PUBLIC ${CMAKE_SOURCE_DIR})
if(GSL_EXTERNAL_PROJECT)
target_include_directories(noname PUBLIC ${install_dir}/include)
target_link_libraries(noname PRIVATE gsl)
else()
# NOTE did not seem to work with PRIVATE (would not find GSL headers)
target_link_libraries(noname PUBLIC GSL::gsl)
endif()
set_target_properties(noname PROPERTIES PUBLIC_HEADER "noname.h")
install (TARGETS noname
PUBLIC_HEADER DESTINATION include
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment