Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .VERSION.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
${PROJECT_VERSION}
90 changes: 19 additions & 71 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
# this software. The contributing author, Izaak Beekman, retains all
# rights permitted by the terms of the JSON-Fortran license.

cmake_minimum_required ( VERSION 2.8.8 FATAL_ERROR )
cmake_minimum_required ( VERSION 3.5 FATAL_ERROR )

# Use MSVS folders to organize projects on windows
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
Expand All @@ -34,7 +34,14 @@ include ( "cmake/checkOutOfSource.cmake" )
#---------------------
# Declare project name
#---------------------
project ( jsonfortran NONE )
project (
jsonfortran
VERSION 8.4.0
LANGUAGES Fortran
)

# write the version file
configure_file(${CMAKE_SOURCE_DIR}/.VERSION.in ${CMAKE_SOURCE_DIR}/.VERSION)

if(CMAKE_Fortran_COMPILER_ID STREQUAL GNU)
option(JSON_FORTRAN_USE_OpenCoarrays
Expand Down Expand Up @@ -70,16 +77,6 @@ elseif(${JSON_INT_KIND} MATCHES "INT64")
add_definitions(-DINT64)
endif()

#----------------------------------
# Get version (semantic versioning)
# C.F. semver.org
#----------------------------------
file ( STRINGS "${PROJECT_SOURCE_DIR}/.VERSION" VERSION )
string( REPLACE "." ";" VERSION_LIST ${VERSION} )
list(GET VERSION_LIST 0 VERSION_MAJOR)
list(GET VERSION_LIST 1 VERSION_MINOR)
list(GET VERSION_LIST 2 VERSION_PATCH)
set(PROJECT_VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}")
message ( STATUS "CMake build configuration for JSON-Fortran ${PROJECT_VERSION}" )

#-------------------------------------
Expand Down Expand Up @@ -170,6 +167,11 @@ set ( LIB_NAME ${PROJECT_NAME} )
add_library ( ${LIB_NAME} SHARED ${JF_LIB_SRCS} )
add_library ( ${LIB_NAME}-static STATIC ${JF_LIB_SRCS} )

# add an alias so that including json-fortran is agnostic
# of find_package or being directly compiled through add_subdirectory
add_library ( ${PACKAGE_NAME}::${LIB_NAME} ALIAS ${LIB_NAME} )
add_library ( ${PACKAGE_NAME}::${LIB_NAME}-static ALIAS ${LIB_NAME}-static )

if(JSON_FORTRAN_USE_OpenCoarrays)
target_link_libraries(${LIB_NAME}
PRIVATE OpenCoarrays::caf_mpi_static)
Expand All @@ -191,7 +193,7 @@ set_target_properties ( ${LIB_NAME}-static
if(NOT MSVC_IDE)
PREFIX lib
endif()
VERSION ${VERSION}
VERSION ${PROJECT_VERSION}
ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib
Fortran_MODULE_DIRECTORY ${MODULE_DIR} )
set_target_properties ( ${LIB_NAME}
Expand All @@ -200,8 +202,8 @@ set_target_properties ( ${LIB_NAME}
if(NOT MSVC_IDE)
PREFIX lib
endif()
SOVERSION ${VERSION_MAJOR}.${VERSION_MINOR}
VERSION ${VERSION}
SOVERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
VERSION ${PROJECT_VERSION}
LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib
Fortran_MODULE_DIRECTORY ${PROJECT_BINARY_DIR} )

Expand Down Expand Up @@ -446,60 +448,6 @@ add_custom_target ( uninstall
#-----------------------------------------------------
# Publicize installed location to other CMake projects
#-----------------------------------------------------
install ( EXPORT ${PACKAGE_NAME}-targets
NAMESPACE ${PACKAGE_NAME}::
DESTINATION "${EXPORT_INSTALL_DIR}" )

include ( CMakePackageConfigHelpers ) # Standard CMake module
write_basic_package_version_file( "${PROJECT_BINARY_DIR}/${PACKAGE_NAME}-config-version.cmake"
VERSION ${VERSION}
COMPATIBILITY SameMajorVersion )

# provides COMPILER_CONSISTENCY_CHECK
include ( cmake/FCompilerConsistencyCheck.cmake )

# install package config file
configure_package_config_file (
"${PROJECT_SOURCE_DIR}/cmake/pkg/${PROJECT_NAME}-config.cmake.in"
"${PROJECT_BINARY_DIR}/pkg/${PACKAGE_NAME}-config.cmake"
INSTALL_DESTINATION "${EXPORT_INSTALL_DIR}"
PATH_VARS EXPORT_INSTALL_DIR INSTALL_MOD_DIR )

# Install the config and version files so that we can find this project with others
install ( FILES
"${PROJECT_BINARY_DIR}/pkg/${PACKAGE_NAME}-config.cmake"
"${PROJECT_BINARY_DIR}/${PACKAGE_NAME}-config-version.cmake"
DESTINATION "${EXPORT_INSTALL_DIR}" )

#----------------------------------------------
# Make build tree targets accessible for import
#----------------------------------------------
export ( TARGETS ${LIB_NAME} ${LIB_NAME}-static FILE ${PACKAGE_NAME}-targets.cmake )

# build tree package config file, NOT installed
configure_file (
"${PROJECT_SOURCE_DIR}/cmake/${PROJECT_NAME}-config.cmake.in"
"${PROJECT_BINARY_DIR}/${PACKAGE_NAME}-config.cmake"
@ONLY )

set ( ENABLE_BUILD_TREE_EXPORT FALSE CACHE BOOL
"Add the ${PACKAGE_NAME} build tree to the CMake package registry?" )
if ( ENABLE_BUILD_TREE_EXPORT )
export ( PACKAGE ${PACKAGE_NAME} )
endif ()

# pkg-config stuff
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/json-fortran.pc.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/json-fortran.pc"
@ONLY
)
install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/json-fortran.pc"
DESTINATION "${INSTALL_LIB_DIR}/pkgconfig"
)

if(MSVC_IDE)
INCLUDE_DIRECTORIES("src")
SET(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fpp")
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
add_subdirectory(packaging)
endif()
57 changes: 57 additions & 0 deletions packaging/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
install ( EXPORT ${PACKAGE_NAME}-targets
NAMESPACE ${PACKAGE_NAME}::
DESTINATION "${EXPORT_INSTALL_DIR}" )

include ( CMakePackageConfigHelpers ) # Standard CMake module
write_basic_package_version_file( "${PROJECT_BINARY_DIR}/${PACKAGE_NAME}-config-version.cmake"
VERSION ${PROJECT_VERSION}
COMPATIBILITY SameMajorVersion )

# provides COMPILER_CONSISTENCY_CHECK
include ( ${PROJECT_SOURCE_DIR}/cmake/FCompilerConsistencyCheck.cmake )

# install package config file
configure_package_config_file (
"${PROJECT_SOURCE_DIR}/cmake/pkg/${PROJECT_NAME}-config.cmake.in"
"${PROJECT_BINARY_DIR}/pkg/${PACKAGE_NAME}-config.cmake"
INSTALL_DESTINATION "${EXPORT_INSTALL_DIR}"
PATH_VARS EXPORT_INSTALL_DIR INSTALL_MOD_DIR )

# Install the config and version files so that we can find this project with others
install ( FILES
"${PROJECT_BINARY_DIR}/pkg/${PACKAGE_NAME}-config.cmake"
"${PROJECT_BINARY_DIR}/${PACKAGE_NAME}-config-version.cmake"
DESTINATION "${EXPORT_INSTALL_DIR}" )

#----------------------------------------------
# Make build tree targets accessible for import
#----------------------------------------------
export ( TARGETS ${LIB_NAME} ${LIB_NAME}-static FILE ${PACKAGE_NAME}-targets.cmake )

# build tree package config file, NOT installed
configure_file (
"${PROJECT_SOURCE_DIR}/cmake/${PROJECT_NAME}-config.cmake.in"
"${PROJECT_BINARY_DIR}/${PACKAGE_NAME}-config.cmake"
@ONLY )

set ( ENABLE_BUILD_TREE_EXPORT FALSE CACHE BOOL
"Add the ${PACKAGE_NAME} build tree to the CMake package registry?" )
if ( ENABLE_BUILD_TREE_EXPORT )
export ( PACKAGE ${PACKAGE_NAME} )
endif ()

# pkg-config stuff
configure_file(
"${PROJECT_SOURCE_DIR}/json-fortran.pc.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/json-fortran.pc"
@ONLY
)
install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/json-fortran.pc"
DESTINATION "${INSTALL_LIB_DIR}/pkgconfig"
)

if(MSVC_IDE)
INCLUDE_DIRECTORIES("src")
SET(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fpp")
endif()
7 changes: 4 additions & 3 deletions pages/development-resources/release-checklist.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ remain accurate.
1. Look at the latest [changes committed to GitHub since the
last release](https://github.com/jacobwilliams/json-fortran/compare/{!.VERSION!}...HEAD),
{!.VERSION!}. This will only be accurate if you have
not yet updated `.VERSION`. If you *have* updated
`.VERSION` then edit the URL manually to view the
not yet updated the project version in cmake. If you *have* updated
the product version in cmake and run cmake (and therefore `.VERSION`) then edit the URL manually to view the
changes.
1. Run the
[`github_changelog_generator`](https://github.com/github-changelog-generator/github-changelog-generator)
Expand Down Expand Up @@ -51,7 +51,8 @@ remain accurate.
string
1. Add `pages/releases/index.md` to the git index: `git add pages/releases/index.md`
1. Update the version string in remaining files requiring manual edits:
1. Edit the `.VERSION` file
1. Edit the product version in CMake
1. Run cmake to generate the `.VERSION` file (or manually update this file if not running CMake)
1. Edit the CMake example on line 141 of `README.md`
1. Edit the `json_fortran_version` string in `json_module.F90`
1. Add these files to the git index: `git add .VERSION README.md ./src/json_module.F90`
Expand Down