Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide cmake config files to be used by users via find_package(CoolProp) #2144

Open
rainman110 opened this issue Jul 14, 2022 · 4 comments · May be fixed by #2148
Open

Provide cmake config files to be used by users via find_package(CoolProp) #2144

rainman110 opened this issue Jul 14, 2022 · 4 comments · May be fixed by #2148

Comments

@rainman110
Copy link

Description

CoolProp creates and installs its C++ library via CMake "make install" target. However, the installed library does not provide a CMake package configuration file, which contains include paths, compiler defines and the link libraries.

It is considered best practice to provide such a configuration file. It allow users of the CoolProp library to use it as

find_package(CoolProp CONFIG)

add_executable(myexe ...)
target_link_libraries(myexe PRIVATE CoolProp)

Steps to Reproduce

  1. try to use CoolProp as a cmake target via find_package
  2. CMake will not find CoolProp

Expected behavior: CoolProp installs the following files in the install step

  • install_prefix/lib/cmake/CoolProp/CoolProp-config.cmake
  • install_prefix/lib/cmake/CoolProp/CoolProp-config-version.cmake
  • install_prefix/lib/cmake/CoolProp/CoolProp-targets.cmake
  • install_prefix/lib/cmake/CoolProp/CoolProp-targets-release.cmake (or debug, depending on the config type)

Actual behavior: No cmake config files are installed, just the library and the header file.

Versions

CoolProp Version: master
Operating System and Version: all
Access Method: using the C++ library

Additional Information

To find out more about cmake target exports and config files, see: https://cliutils.gitlab.io/modern-cmake/chapters/install/installing.html

@ibell
Copy link
Contributor

ibell commented Jul 14, 2022 via email

@rainman110
Copy link
Author

rainman110 commented Jul 15, 2022

Pull request welcome adding this

Awesome, I'll try to create a PR in the next days.

I've noticed though, that you use a user-defined target name for the library. Do you really need this or does a fixed target name with a user defined library file name is sufficient? This will make the use from the users point of view much easier since the user knows, which target to link against (even though the resulting library file name might be different).

@ibell
Copy link
Contributor

ibell commented Jul 15, 2022 via email

rainman110 added a commit to rainman110/CoolProp that referenced this issue Aug 1, 2022
The user can still specify the output / file name
of the library as I used

  set_target_properties(CoolProp PROPERTIES OUTPUT_NAME ${LIB_NAME})

to rename the library.

Addresses CoolProp#2144
rainman110 added a commit to rainman110/CoolProp that referenced this issue Aug 1, 2022
This notifies cmake that only coolprop
requires dl for building the library
but dl is not part of the public interface
is hence is not a direct dependency for the user.

Addresses CoolProp#2144
rainman110 added a commit to rainman110/CoolProp that referenced this issue Aug 1, 2022
rainman110 added a commit to rainman110/CoolProp that referenced this issue Aug 1, 2022
This should avoid conflicting the library target name
when creating snippet executables.

Addresses CoolProp#2144
rainman110 added a commit to rainman110/CoolProp that referenced this issue Aug 1, 2022
rainman110 added a commit to rainman110/CoolProp that referenced this issue Aug 1, 2022
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
rainman110 added a commit to rainman110/CoolProp that referenced this issue Aug 1, 2022
This is the entry point for cmake to
make find_package(CoolProp) work.

Closes CoolProp#2144
rainman110 added a commit to rainman110/CoolProp that referenced this issue Aug 1, 2022
This makes sure, that we dont get any linker
error if we are linking against coolprop
without any additional compiler switches.

Fixes CoolProp#2144
@rainman110
Copy link
Author

@ibell It took me a while to find some free time for CoolProp, but today I managed to open a PR that adds cmake config file support.

I am happy to discuss the details with you.

rainman110 added a commit to rainman110/CoolProp that referenced this issue Aug 5, 2022
@jowr jowr added this to the v6.5.0 milestone Dec 8, 2022
@ibell ibell modified the milestones: v6.5.0, v6.4.3 Aug 6, 2023
@jowr jowr removed this from the v6.4.3 milestone Nov 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants