Skip to content

Commit ad6c39a

Browse files
committed
Merge pull request #101 from zbeekman/GNU-install-structure
Gnu install structure
2 parents 2f8c9c4 + f8ddcd8 commit ad6c39a

File tree

2 files changed

+32
-10
lines changed

2 files changed

+32
-10
lines changed

CMakeLists.txt

+31-9
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ project ( jsonfortran NONE )
3434
# C.F. semver.org
3535
#----------------------------------
3636
set ( VERSION_MAJOR 4 )
37-
set ( VERSION_MINOR 0 )
37+
set ( VERSION_MINOR 1 )
3838
set ( VERSION_PATCH 0 )
3939
set ( VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}" )
4040

@@ -49,27 +49,40 @@ set ( JF_TEST_UCS4_SUPPORT_SRC "${CMAKE_SOURCE_DIR}/src/tests/introspection/test
4949
# Collect all the mod files into their own
5050
# directory to ease installation issues
5151
#-----------------------------------------
52-
set ( MODULE_DIR "${CMAKE_BINARY_DIR}/lib" )
52+
set ( MODULE_DIR "${CMAKE_BINARY_DIR}/include" )
5353

5454
#-------------------------------------
5555
# Define where our files get installed
5656
#-------------------------------------
57+
set ( USE_GNU_INSTALL_CONVENTION FALSE
58+
CACHE BOOL
59+
"Install library, module file and documentation to standard GNU locations. Do not use this if supporting multiple Fortran compilers" )
60+
5761
# Set the package name to be specific to the compiler used, so that
5862
# versions compiled with different compilers can be installed in parallel
5963
string ( TOLOWER ${CMAKE_PROJECT_NAME}-${CMAKE_Fortran_COMPILER_ID} PACKAGE_NAME )
60-
string ( TOLOWER ${CMAKE_Fortran_COMPILER_ID}-compiler FCOMPILER_DIR )
6164
set ( PACKAGE_VERSION "${PACKAGE_NAME}-${VERSION}" )
6265

66+
if (USE_GNU_INSTALL_CONVENTION)
67+
include(GNUInstallDirs)
68+
set ( INSTALL_MOD_DIR "${CMAKE_INSTALL_INCLUDEDIR}" )
69+
set ( INSTALL_LIB_DIR "${CMAKE_INSTALL_LIBDIR}")
70+
set( ABS_LIB_INSTALL_DIR "\${CMAKE_INSTALL_FULL_LIBDIR}" )
71+
else ()
72+
# Most of this could be 'wrong' for Windows/Cygwin
73+
set ( INSTALL_MOD_DIR "${PACKAGE_VERSION}/lib" )
74+
set ( INSTALL_LIB_DIR "${INSTALL_MOD_DIR}" )
75+
set( ABS_LIB_INSTALL_DIR "\${CMAKE_INSTALL_PREFIX}/${INSTALL_LIB_DIR}" )
76+
endif ()
6377

64-
# Most of this could be 'wrong' for Windows/Cygwin
65-
66-
set ( INSTALL_MOD_DIR "${PACKAGE_VERSION}/lib" )
67-
set ( INSTALL_LIB_DIR "${INSTALL_MOD_DIR}" )
68-
set( ABS_LIB_INSTALL_DIR "\${CMAKE_INSTALL_PREFIX}/${INSTALL_LIB_DIR}" )
6978

7079
# Put package export CMake files where they can be found
7180
# use `find_package ( jsonfortran-${CMAKE_Fortran_COMPILER_ID} <version> REQUIRED )`
72-
set ( EXPORT_INSTALL_DIR "${PACKAGE_VERSION}/cmake" )
81+
if (USE_GNU_INSTALL_CONVENTION)
82+
set ( EXPORT_INSTALL_DIR "${INSTALL_LIB_DIR}/cmake/${PACKAGE_VERSION}" )
83+
else ()
84+
set ( EXPORT_INSTALL_DIR "${PACKAGE_VERSION}/cmake" )
85+
endif ()
7386

7487
if ( "${CMAKE_SYSTEM_NAME}" MATCHES "Darwin" )
7588
set ( ENABLE_DYLIBS_USE_RPATH TRUE CACHE BOOL
@@ -157,6 +170,15 @@ if ( NOT SKIP_DOC_GEN )
157170
COMMENT "Building HTML documentation for ${CMAKE_PROJECT_NAME} using ROBODoc" )
158171
add_custom_target ( documentation ALL
159172
DEPENDS ${ROBODOC_OUTPUTS} )
173+
set ( INSTALL_API_DOCUMENTATION TRUE
174+
CACHE BOOL "Install ROBODoc generated documentation?" )
175+
if ( INSTALL_API_DOCUMENTATION )
176+
if ( USE_GNU_INSTALL_CONVENTION )
177+
install ( DIRECTORY "${DOC_DIR}/" DESTINATION "${CMAKE_INSTALL_DOCDIR}" )
178+
else ()
179+
install ( DIRECTORY "${DOC_DIR}/" DESTINATION "${CMAKE_INSTALL_PREFIX}/${PACKAGE_VERSION}/doc" )
180+
endif ()
181+
endif ()
160182
else () # Not found
161183
message ( WARNING
162184
"ROBODoc not found! Please set the CMake cache variable ROBODOC to point to the installed ROBODoc binary, and reconfigure or disable building the documentation. ROBODoc can be installed from: http://www.xs4all.nl/~rfsber/Robo/ If you do not wish to install ROBODoc and build the json-fortran documentation, then please set the CMake cache variable SKIP_DOC_GEN to TRUE." )

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ cmake_minimum_required ( VERSION 2.8.8 FATAL_ERROR )
6363
enable_language ( Fortran )
6464
project ( jf_test NONE )
6565
66-
find_package ( jsonfortran-${CMAKE_Fortran_COMPILER_ID} 4.0.0 REQUIRED )
66+
find_package ( jsonfortran-${CMAKE_Fortran_COMPILER_ID} 4.1.0 REQUIRED )
6767
6868
file ( GLOB JF_TEST_SRCS "src/tests/jf_test_*.f90" )
6969
foreach ( UNIT_TEST ${JF_TEST_SRCS} )

0 commit comments

Comments
 (0)