Skip to content
This repository has been archived by the owner on Aug 28, 2024. It is now read-only.

Commit

Permalink
Simplified the cmake files for Cython and improved the ability to pac…
Browse files Browse the repository at this point in the history
…kage the wheel
  • Loading branch information
MintoDA1 authored and MintoDA1 committed Sep 13, 2023
1 parent de68a73 commit 5980806
Show file tree
Hide file tree
Showing 10 changed files with 37 additions and 2,056 deletions.
46 changes: 15 additions & 31 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,24 @@ IF (${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.27")
ENDIF ()

INCLUDE(GNUInstallDirs)
IF (SKBUILD)
SET(INSTALL_BINDIR ${SKBUILD_PLATLIB_DIR}/${SKBUILD_PROJECT_NAME})
SET(INSTALL_LIBDIR ${SKBUILD_PLATLIB_DIR}/${SKBUILD_PROJECT_NAME})
SET(INSTALL_INCLUDEDIR ${INSTALL_LIBDIR})
ELSE ()
SET(INSTALL_BINDIR ${CMAKE_INSTALL_BINDIR})
SET(INSTALL_LIBDIR ${CMAKE_INSTALL_LIBDIR})
SET(INSTALL_INCLUDEDIR ${CMAKE_INSTALL_INCLUDEDIR})
ENDIF ()


# Have the .mod files placed in the include folder
SET(CMAKE_Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/mod)

# Add our local modules to the module path
FILE(TO_CMAKE_PATH "${CMAKE_SOURCE_DIR}/cmake/Modules" LOCAL_MODULE_PATH)
LIST(APPEND CMAKE_MODULE_PATH ${LOCAL_MODULE_PATH})

SET(CYTHON_FLAGS
"--directive binding=True,boundscheck=False,wraparound=False,embedsignature=True,always_allow_keywords=True"
CACHE STRING "The directives for Cython compilation.")
FIND_PACKAGE(Cython REQUIRED)
FIND_PACKAGE(PythonExtensions REQUIRED)

IF (CMAKE_Fortran_COMPILER_ID MATCHES "^Intel")
SET(COMPILER_OPTIONS "Intel" CACHE STRING "Compiler identified as Intel")
ELSEIF (CMAKE_Fortran_COMPILER_ID STREQUAL "GNU")
Expand Down Expand Up @@ -75,30 +83,6 @@ ENDIF(WIN32)
FILE(TO_CMAKE_PATH ${SRC} SRC)
FILE(TO_CMAKE_PATH ${PY} PY)

# Have the .mod files placed in the include folder
SET(CMAKE_Fortran_MODULE_DIRECTORY ${CMAKE_INSTALL_INCLUDEDIR})

# use, i.e. don't skip the full RPATH for the build tree
set(CMAKE_SKIP_BUILD_RPATH FALSE)

# when building, don't use the install RPATH already
# (but later on when installing)
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)

# If we are using Scikit-Build, be sure to set install paths correctly
if (SKBUILD)
find_package(PythonExtensions REQUIRED)
set(lib_path "${PYTHON_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
else()
set(lib_path "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
endif()

set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")

# add the automatically determined parts of the RPATH
# which point to directories outside the build tree to the install RPATH
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)

# Set the name of the swiftest library
SET(SWIFTEST_LIBRARY ${SKBUILD_PROJECT_NAME})

Expand All @@ -109,4 +93,4 @@ ADD_SUBDIRECTORY(${PY})
# Add a distclean target to the Makefile
ADD_CUSTOM_TARGET(distclean
COMMAND ${CMAKE_COMMAND} -P "${CMAKE_SOURCE_DIR}/distclean.cmake"
)
)
2 changes: 1 addition & 1 deletion buildscripts/set_environment.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ HOMEBREW_PREFIX="$(brew --prefix)"
LD_LIBRARY_PATH="/usr/local/lib:${PREFIX}/lib:${HOMEBREW_PREFIX}/lib"
LDFLAGS="-Wl,-rpath,${ROOT_DIR}/lib -Wl,-no_compact_unwind -L${PREFIX}/lib -L${HOMEBREW_PREFIX}/lib"
CPATH="/usr/local/include:${PREFIX}/include:${HOMEBREW_PREFIX}/include:${ROOT_DIR}/include"
CPPFLAGS="-isystem ${PREFIX}/include -isystem /usr/local/include"
CPPFLAGS="-isystem ${PREFIX}/include -isystem /usr/local/include -Xclang -fopenmp"
LIBS="-lomp"
FCFLAGS="-mmacosx-version-min=${MACOSX_DEPLOYMENT_TARGET}"
FFFLAGS="${FCFLAGS}"
Expand Down
88 changes: 0 additions & 88 deletions cmake/Modules/FindCython.cmake

This file was deleted.

Loading

0 comments on commit 5980806

Please sign in to comment.