diff --git a/CMakeLists.txt b/CMakeLists.txt index 2ee28f6..ee1ec5d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,10 +3,10 @@ ################### cmake_minimum_required(VERSION 3.10) - -set(PDAF_FLAGS "-fPIC") project(OGS-PDAF Fortran) -add_definitions(${PDAF_FLAGS}) +set(CMAKE_POSITION_INDEPENDENT_CODE ON) +set(BUILD_SHARED_LIBS ON) +add_subdirectory(pdaf_base/src) add_subdirectory(pdaf_user) diff --git a/README.md b/README.md new file mode 100644 index 0000000..eadba8a --- /dev/null +++ b/README.md @@ -0,0 +1,11 @@ +# PDAF-OGS module + +## Build + +```bash +mkdir build; cd build +FC=mpif90 cmake ../[path-to-sources] +make +``` + +Find the shared library `pdaf` in `build/pdaf_user/`. diff --git a/pdaf_base/CMakeLists.txt b/pdaf_base/CMakeLists.txt deleted file mode 100644 index c36c6c8..0000000 --- a/pdaf_base/CMakeLists.txt +++ /dev/null @@ -1,12 +0,0 @@ -######################## -### OGS-PDAF-Base ###### -######################## - -cmake_minimum_required(VERSION 3.10) - -set(PDAF_FLAGS "-fdefault-real-8 -fPIC -O3") -project(OGS-PDAF-Base Fortran) - -add_definitions(${PDAF_FLAGS}) - -add_subdirectory(src) diff --git a/pdaf_base/src/CMakeLists.txt b/pdaf_base/src/CMakeLists.txt index 3ec5eb0..be480d6 100644 --- a/pdaf_base/src/CMakeLists.txt +++ b/pdaf_base/src/CMakeLists.txt @@ -1,5 +1,5 @@ file(GLOB PDAF_BASE_SOURCES *.F90) -include_directories(dummympi) - -add_library(PDAF_base ${PDAF_BASE_SOURCES}) +add_library(PDAF_base STATIC ${PDAF_BASE_SOURCES}) +target_include_directories(PDAF_base PRIVATE dummympi) +target_compile_options(PDAF_base PRIVATE "-fdefault-real-8") diff --git a/pdaf_user/CMakeLists.txt b/pdaf_user/CMakeLists.txt index ed1a140..c12d444 100644 --- a/pdaf_user/CMakeLists.txt +++ b/pdaf_user/CMakeLists.txt @@ -1,9 +1,9 @@ -cmake_minimum_required(VERSION 3.10) - file(GLOB PDAF_USER_SOURCES *.F90) -include_directories(dummympi) +add_library(pdaf ${PDAF_USER_SOURCES}) +target_include_directories(pdaf PRIVATE dummympi) +target_link_libraries(pdaf PRIVATE PDAF_base) -add_library(PDAF_user SHARED ${PDAF_USER_SOURCES}) -set_target_properties(PDAF_user PROPERTIES PREFIX "") -set_target_properties(PDAF_user PROPERTIES OUTPUT_NAME "pdaf") +if(APPLE AND BUILD_SHARED_LIBS) + target_link_libraries(pdaf PUBLIC "-framework Accelerate") +endif() diff --git a/pdaf_user/cmake_install.cmake b/pdaf_user/cmake_install.cmake deleted file mode 100644 index 7ce79e7..0000000 --- a/pdaf_user/cmake_install.cmake +++ /dev/null @@ -1,39 +0,0 @@ -# Install script for directory: /home/schueler/repo/fortran/pdaf/pdaf_user - -# Set the install prefix -if(NOT DEFINED CMAKE_INSTALL_PREFIX) - set(CMAKE_INSTALL_PREFIX "/usr/local") -endif() -string(REGEX REPLACE "/$" "" CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}") - -# Set the install configuration name. -if(NOT DEFINED CMAKE_INSTALL_CONFIG_NAME) - if(BUILD_TYPE) - string(REGEX REPLACE "^[^A-Za-z0-9_]+" "" - CMAKE_INSTALL_CONFIG_NAME "${BUILD_TYPE}") - else() - set(CMAKE_INSTALL_CONFIG_NAME "") - endif() - message(STATUS "Install configuration: \"${CMAKE_INSTALL_CONFIG_NAME}\"") -endif() - -# Set the component getting installed. -if(NOT CMAKE_INSTALL_COMPONENT) - if(COMPONENT) - message(STATUS "Install component: \"${COMPONENT}\"") - set(CMAKE_INSTALL_COMPONENT "${COMPONENT}") - else() - set(CMAKE_INSTALL_COMPONENT) - endif() -endif() - -# Install shared libraries without execute permission? -if(NOT DEFINED CMAKE_INSTALL_SO_NO_EXE) - set(CMAKE_INSTALL_SO_NO_EXE "1") -endif() - -# Is this installation the result of a crosscompile? -if(NOT DEFINED CMAKE_CROSSCOMPILING) - set(CMAKE_CROSSCOMPILING "FALSE") -endif() -