Merge pull request #1199 from muemart/gsl-cblas

Fix GSL port so that CMake can find it
This commit is contained in:
Robert Schumacher 2017-05-31 23:43:54 -07:00 committed by GitHub
commit 14e1886d6a
2 changed files with 19 additions and 8 deletions

View File

@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.8)
project(libgsl C)
project(gsl C)
option(INSTALL_HEADERS "Install public header files" ON)
@ -27,10 +27,15 @@ function(extract_sources SUBFOLDER ALLSOURCES)
endfunction(extract_sources)
set(SOURCES)
set(CBLAS_SOURCES)
extract_from_makefile("SUBDIRS = ([^\n]*)" FOLDERS "./Makefile.am")
extract_sources("." SOURCES)
foreach(DIR IN LISTS FOLDERS)
extract_sources("${DIR}" SOURCES)
if("${DIR}" STREQUAL "cblas")
extract_sources("${DIR}" CBLAS_SOURCES)
else()
extract_sources("${DIR}" SOURCES)
endif()
endforeach()
file(READ gsl_types.h GSLTYPES_H)
@ -43,13 +48,19 @@ file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/gsl_types.h "${GSLTYPES_H}")
file(GLOB_RECURSE PUBLIC_HEADERS gsl*.h)
list(APPEND PUBLIC_HEADERS ${CMAKE_CURRENT_BINARY_DIR}/gsl_types.h)
add_library(libgsl ${SOURCES})
set_target_properties(libgsl PROPERTIES DEFINE_SYMBOL DLL_EXPORT WINDOWS_EXPORT_ALL_SYMBOLS ON)
add_library(gslcblas ${CBLAS_SOURCES})
set_target_properties(gslcblas PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON)
add_library(gsl ${SOURCES})
set_target_properties(gsl PROPERTIES DEFINE_SYMBOL DLL_EXPORT WINDOWS_EXPORT_ALL_SYMBOLS ON)
target_link_libraries(gsl PUBLIC gslcblas)
if(INSTALL_HEADERS)
set_target_properties(libgsl PROPERTIES PUBLIC_HEADER "${PUBLIC_HEADERS}")
set_target_properties(gsl PROPERTIES PUBLIC_HEADER "${PUBLIC_HEADERS}")
endif()
target_include_directories(libgsl PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_include_directories(gslcblas PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_include_directories(gsl PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
# For the build, we need to copy all headers to the gsl directory
file(COPY ${PUBLIC_HEADERS} DESTINATION "${CMAKE_CURRENT_SOURCE_DIR}/gsl")
@ -58,7 +69,7 @@ if(INSTALL_HEADERS)
set(TARGET_INSTALL_OPTIONS PUBLIC_HEADER DESTINATION include/gsl)
endif()
install(TARGETS libgsl
install(TARGETS gsl gslcblas
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib

View File

@ -1,3 +1,3 @@
Source: gsl
Version: 2.3
Version: 2.3-1
Description: The GNU Scientific Library is a numerical library for C and C++ programmers