diff --git a/CMakeLists.txt b/CMakeLists.txt index 96d7733c6..4b4faf4d4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,6 +19,19 @@ SET(SKBUILD_SCRIPTS_DIR "${CMAKE_SOURCE_DIR}/bin" CACHE STRING "Install location FILE(READ "version.txt" VERSION) PROJECT(${SKBUILD_PROJECT_NAME} LANGUAGES C Fortran VERSION ${VERSION}) +# Use the old method to get Python packages, as that's what scikit-build uses +CMAKE_POLICY(SET CMP0148 OLD) + +# 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") @@ -41,31 +54,39 @@ ENDIF() # Ensure scikit-build modules FIND_PACKAGE(Python COMPONENTS Interpreter Development.Module REQUIRED) -# 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}) # Define some directories that are important to the build SET(SRC "${CMAKE_SOURCE_DIR}/src") -SET(LIB "${CMAKE_SOURCE_DIR}/lib") -SET(BIN "${CMAKE_SOURCE_DIR}/bin") -SET(MOD "${CMAKE_SOURCE_DIR}/include") SET(PY "${CMAKE_SOURCE_DIR}/swiftest") # Make sure paths are correct for Unix or Windows style FILE(TO_CMAKE_PATH ${SRC} SRC) -FILE(TO_CMAKE_PATH ${LIB} LIB) -FILE(TO_CMAKE_PATH ${BIN} BIN) -FILE(TO_CMAKE_PATH ${MOD} MOD) FILE(TO_CMAKE_PATH ${PY} PY) -set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${LIB}) -set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${LIB}) -set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${BIN}) - # Have the .mod files placed in the lib folder SET(CMAKE_Fortran_MODULE_DIRECTORY ${MOD}) +# 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 +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 swiftest) @@ -77,4 +98,4 @@ ADD_SUBDIRECTORY(${PY}) # Add a distclean target to the Makefile ADD_CUSTOM_TARGET(distclean COMMAND ${CMAKE_COMMAND} -P "${CMAKE_SOURCE_DIR}/distclean.cmake" -) +) \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index f829a3577..3712bf473 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "swiftest" -version = "2023.9.1" +version = "2023.9.2" authors=[ {name = 'David A. Minton', email='daminton@purdue.edu'}, {name = 'Carlisle Wishard'}, diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 1a4dc45d0..b8dd5730d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -162,7 +162,6 @@ IF (CMAKE_SYSTEM_NAME STREQUAL "Windows") SET_PROPERTY(TARGET ${SWIFTEST_LIBRARY} ${SWIFTEST_DRIVER} APPEND_STRING PROPERTY LINK_FLAGS "/NODEFAULTLIB") ENDIF() - IF(USE_COARRAY) TARGET_COMPILE_DEFINITIONS(${SWIFTEST_LIBRARY} PUBLIC -DCOARRAY) TARGET_COMPILE_DEFINITIONS(${SWIFTEST_DRIVER} PUBLIC -DCOARRAY) @@ -209,7 +208,6 @@ ELSE () MESSAGE(STATUS "Quad precision real is not supported") ENDIF () - ##################################### # Tell how to install this executable ##################################### @@ -220,9 +218,22 @@ ELSE() SET(CMAKE_INSTALL_PREFIX /usr/local) ENDIF(WIN32) INSTALL(TARGETS ${SWIFTEST_DRIVER} ${SWIFTEST_LIBRARY} - RUNTIME DESTINATION bin - LIBRARY DESTINATION lib - ARCHIVE DESTINATION lib - INCLUDES DESTINATION include + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} ) +# the RPATH to be used when installing, but only if it's not a system directory +LIST(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/lib" isSystemDir) +IF("${isSystemDir}" STREQUAL "-1") + SET_TARGET_PROPERTIES(${CTEM_DRIVER} PROPERTIES + INSTALL_RPATH_USE_LINK_PATH TRUE + INSTALL_RPATH "${lib_path}") + # The following is necessary for installation in a virtual + # environment `python -m pip venv env` + set_target_properties(${SWIFTEST_LIBRARY} PROPERTIES + INSTALL_RPATH_USE_LINK_PATH TRUE + INSTALL_RPATH "${lib_path}") +endif("${isSystemDir}" STREQUAL "-1") + diff --git a/src/globals/globals_module.f90 b/src/globals/globals_module.f90 index ffc1854ab..85a0e9fc6 100644 --- a/src/globals/globals_module.f90 +++ b/src/globals/globals_module.f90 @@ -48,7 +48,7 @@ module globals integer(I4B), parameter :: UPPERCASE_OFFSET = iachar('A') - iachar('a') !! ASCII character set parameter for lower to upper !! conversion - offset between upper and lower - character(*), parameter :: VERSION = "" !! Swiftest version + character(*), parameter :: VERSION = "2023.9.2" !! Swiftest version !> Symbolic name for integrator types character(*), parameter :: UNKNOWN_INTEGRATOR = "UKNOWN INTEGRATOR" diff --git a/swiftest/CMakeLists.txt b/swiftest/CMakeLists.txt index 6bdf332d1..4e32a6fe9 100644 --- a/swiftest/CMakeLists.txt +++ b/swiftest/CMakeLists.txt @@ -7,15 +7,6 @@ # You should have received a copy of the GNU General Public License along with Swiftest. # If not, see: https://www.gnu.org/licenses. -# Use the old method to get Python packages, as that's what scikit-build uses -CMAKE_POLICY(SET CMP0148 OLD) - -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) - # Avoid Cython/Python3.8 minor incompatibility warnings, see # https://github.com/cython/cython/issues/3474. Note that this option is a bit # expansive, but it's a temporary fix and we'll be testing on other Python