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

Link against libz and pthread privately #258

Merged
merged 24 commits into from
Aug 21, 2024
Merged

Link against libz and pthread privately #258

merged 24 commits into from
Aug 21, 2024

Conversation

nsmith-
Copy link
Collaborator

@nsmith- nsmith- commented Aug 19, 2024

Fixes #235

Tested by creating CMakeLists.txt:

cmake_minimum_required(VERSION 3.16 FATAL_ERROR)
project(test)
find_package(correctionlib)
add_executable(test test.cc)
target_link_libraries(test correctionlib)

and test.cc:

#include "correction.h"

using correction::CorrectionSet;

int main(int argc, char** argv) {
  auto cset = CorrectionSet::from_file("electron.json");
  auto corr = cset->at("corr");
}

and confirming cmake $(correction config --cmake) . && make completed successfully. Without this patch, I get the error

CMake Error at /Users/ncsmith/src/correctionlib/.env/lib/python3.12/site-packages/correctionlib/cmake/correctionlib-targets.cmake:60 (set_target_properties):
  The link interface of target "correctionlib" contains:

    ZLIB::ZLIB

  but the target was not found.  Possible reasons include:

    * There is a typo in the target name.
    * A find_package call is missing for an IMPORTED target.
    * An ALIAS target is missing.

Call Stack (most recent call first):
  /Users/ncsmith/src/correctionlib/.env/lib/python3.12/site-packages/correctionlib/cmake/correctionlibConfig.cmake:10 (include)
  CMakeLists.txt:3 (find_package)

@nsmith-
Copy link
Collaborator Author

nsmith- commented Aug 19, 2024

@lmoureaux sorry this fell off my radar. Take a look

@lmoureaux
Copy link

No worries, we're all very busy :) This is the error I was reporting and one of the proposed solutions, so I'm happy!

I'm wondering if this could be used as a basic test of the C++ interface. It seems there is currently none?

@nsmith-
Copy link
Collaborator Author

nsmith- commented Aug 19, 2024

There is only a test through the PyROOT binding at the moment:

ROOT.gInterpreter.Declare(
f'auto cset = correction::CorrectionSet::from_string("{csetstr}");' # noqa: B907
)
ROOT.gInterpreter.Declare('auto corr = cset->at("ptweight");')
assert ROOT.corr.evaluate([1.2]) == 1.1

but yes it would be good to verify the static compilation

Copy link

@lmoureaux lmoureaux left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome!

@nsmith-
Copy link
Collaborator Author

nsmith- commented Aug 21, 2024

There is some issue with compiling and running this test example that I cannot debug as I don't have a windows machine. Calling it good enough without.

@nsmith- nsmith- added this pull request to the merge queue Aug 21, 2024
Merged via the queue into master with commit 79832f6 Aug 21, 2024
11 checks passed
@nsmith- nsmith- deleted the fixcmake235 branch August 21, 2024 03:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

The exported CMake configuration doesn't look for dependencies correctly
2 participants