Skip to content

Commit

Permalink
small update to the CMakeLists.txt files, feedback on locations lib/h…
Browse files Browse the repository at this point in the history
…eaders
  • Loading branch information
repagh authored and roryyorke committed May 3, 2020
1 parent dec9f58 commit 1bf49c1
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 23 deletions.
25 changes: 13 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
# CMake file for use in conjunction with scikit-build

cmake_minimum_required(VERSION 3.4.0)
cmake_minimum_required(VERSION 3.11.0)

if (CMAKE_VERSION VERSION_GREATER "3.11.99")
cmake_policy(SET CMP0074 NEW)
endif()

project(slycot VERSION ${SLYCOT_VERSION} LANGUAGES NONE)

# Fortran detection fails on windows, use the CMAKE_C_SIMULATE flag to
# force success
if(WIN32)
Expand All @@ -19,12 +18,24 @@ endif()
enable_language(C)
enable_language(Fortran)

# base site dir, use python installation for location specific includes
execute_process(
COMMAND "${PYTHON_EXECUTABLE}" -c
"import os,numpy; print(os.path.dirname(numpy.__path__[0]))"
OUTPUT_VARIABLE PYTHON_SITE
OUTPUT_STRIP_TRAILING_WHITESPACE)
if(WIN32)
string(REPLACE "\\" "/" PYTHON_SITE ${PYTHON_SITE})
endif()

find_package(PythonLibs REQUIRED)
find_package(NumPy REQUIRED)
find_package(BLAS REQUIRED)
find_package(LAPACK REQUIRED)

message(STATUS "NumPy: ${NumPy_INCLUDE_DIR}")
message(STATUS "LAPACK: ${LAPACK_LIBRARIES}")
message(STATUS "BLAS: ${BLAS_LIBRARIES}")
message(STATUS "Slycot version: ${SLYCOT_VERSION}")

# find python, standard packages, F2PY find flaky on Windows
Expand All @@ -37,15 +48,5 @@ if (WIN32)
set(CMAKE_Fortran_COMPILE_OPTIONS_PIC "")
endif()

# base site dir, use python installation for location specific includes
execute_process(
COMMAND "${PYTHON_EXECUTABLE}" -c
"import os,numpy; print(os.path.dirname(numpy.__path__[0]))"
OUTPUT_VARIABLE PYTHON_SITE
OUTPUT_STRIP_TRAILING_WHITESPACE)
if(WIN32)
string(REPLACE "\\" "/" PYTHON_SITE ${PYTHON_SITE})
endif()

add_subdirectory(slycot)

24 changes: 13 additions & 11 deletions slycot/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -131,21 +131,29 @@ set(CMAKE_Fortran_FLAGS )

add_custom_target(wrapper ALL DEPENDS ${FSOURCES})
add_custom_command(
OUTPUT SLYCOTmodule.c _wrappermodule.c _wrapper-f2pywrappers.f
OUTPUT _wrappermodule.c _wrapper-f2pywrappers.f
COMMAND ${F2PY_EXECUTABLE} -m SLYCOT
${CMAKE_CURRENT_SOURCE_DIR}/${F2PYSOURCE}
DEPENDS ${F2PYSOURCE_DEPS} ${F2PYSOURCE}
)

add_library(
${SLYCOT_MODULE} MODULE
SLYCOTmodule.c _wrappermodule.c _wrapper-f2pywrappers.f
"${PYTHON_SITE}/numpy/f2py/src/fortranobject.c"
_wrappermodule.c
${PYTHON_SITE}/numpy/f2py/src/fortranobject.c
_wrapper-f2pywrappers.f
${FSOURCES})

target_link_libraries(${SLYCOT_MODULE}
${LAPACK_LIBRARIES})

target_include_directories(
${SLYCOT_MODULE} PUBLIC
${PYTHON_SITE}/numpy/core/include
${PYTHON_SITE}/numpy/f2py/src
${PYTHON_INCLUDE_DIRS}
)

if (UNIX)
if (APPLE)
set_target_properties(${SLYCOT_MODULE} PROPERTIES
Expand All @@ -156,15 +164,9 @@ if (UNIX)
endif()
endif()

target_include_directories(
${SLYCOT_MODULE} PUBLIC
${PYTHON_SITE}/numpy/core/include
${PYTHON_SITE}/numpy/f2py/src
${PYTHON_INCLUDE_DIRS}
)

python_extension_module(${SLYCOT_MODULE})
install(TARGETS ${SLYCOT_MODULE} DESTINATION slycot)

install(TARGETS ${SLYCOT_MODULE} LIBRARY DESTINATION slycot)
install(FILES ${PYSOURCE} DESTINATION slycot)

add_subdirectory(tests)

0 comments on commit 1bf49c1

Please sign in to comment.