Skip to content

Commit

Permalink
Link headers to exported library
Browse files Browse the repository at this point in the history
This allows to use the CoolProp library
from cmake by simply linking against it,
without to specify any additional include paths
for the coolprop public header file.

Addresses CoolProp#2144
  • Loading branch information
rainman110 committed Aug 1, 2022
1 parent 74c3f0c commit 082919f
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -545,8 +545,7 @@ if(COOLPROP_OBJECT_LIBRARY
DESTINATION
static_library/${CMAKE_SYSTEM_NAME}/${BITNESS}bit_${CMAKE_CXX_COMPILER_ID}_${CMAKE_CXX_COMPILER_VERSION}
)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${COOLPROP_LIBRARY_HEADER}
DESTINATION static_library)
set(CoolPropLibDestination "static_library")
elseif(COOLPROP_SHARED_LIBRARY)
list(APPEND APP_SOURCES
"${CMAKE_CURRENT_SOURCE_DIR}/${COOLPROP_LIBRARY_SOURCE}")
Expand All @@ -556,8 +555,7 @@ if(COOLPROP_OBJECT_LIBRARY
EXPORT CoolProp-targets
DESTINATION shared_library/${CMAKE_SYSTEM_NAME}/${BITNESS}bit${CONVENTION}
)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${COOLPROP_LIBRARY_HEADER}
DESTINATION shared_library)
set(CoolPropLibDestination "shared_library")
set_property(
TARGET CoolPropLib
APPEND_STRING
Expand Down Expand Up @@ -600,6 +598,15 @@ if(COOLPROP_OBJECT_LIBRARY

set(COOLPROP_CMAKE_DIR "lib/cmake/CoolProp")

# install the public header file
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${COOLPROP_LIBRARY_HEADER}
DESTINATION ${CoolPropLibDestination})

# link header file to library
target_include_directories(CoolPropLib PUBLIC
$<INSTALL_INTERFACE:${CoolPropLibDestination}>
)

# install exports
install (
EXPORT CoolProp-targets
Expand Down

0 comments on commit 082919f

Please sign in to comment.