-
Notifications
You must be signed in to change notification settings - Fork 88
Open
Labels
Description
According to the README json-fortran can be used in a CMake project by linking the library jsonfortran::jsonfortran
or jsonfortran::jsonfortran-static
:
Line 151 in cde2620
target_link_libraries ( ${TEST} jsonfortran::jsonfortran-static ) |
However the installation means that a different name library name is used for every installation. This comes from here:
Lines 111 to 114 in cde2620
# Set the package name to be specific to the compiler used, so that | |
# versions compiled with different compilers can be installed in parallel | |
string ( TOLOWER ${PROJECT_NAME}-${CMAKE_Fortran_COMPILER_ID} PACKAGE_NAME ) | |
set ( PACKAGE_VERSION "${PACKAGE_NAME}-${PROJECT_VERSION}" ) |
The library names are therefore actually more like: jsonfortran-nvhpc::jsonfortran
. This is particularly cumbersome as the compiler id in CMake is uppercase but the library uses lowercase.
As a workaround it is possible to use the documented name by doing:
# Get compiler dependent name
string(TOLOWER "jsonfortran-${CMAKE_Fortran_COMPILER_ID}" jsonlibname)
# Create alias
add_library(jsonfortran::jsonfortran ALIAS ${jsonlibname}::jsonfortran)
however it would be simpler if jsonfortran simply installed itself with the documented name