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

dcm2niix does not find yaml-cpp by CMake config #647

Closed
hobbes1069 opened this issue Nov 10, 2022 · 1 comment
Closed

dcm2niix does not find yaml-cpp by CMake config #647

hobbes1069 opened this issue Nov 10, 2022 · 1 comment

Comments

@hobbes1069
Copy link

Describe the bug

Current version does not properly find yaml-cpp when using CMake config files.

When dependencies are found by config instead by module (Find.cmake) the typical variables are not necessarily set. Instead specifying link libraries are done by imported targets.

Here's a minimal patch used to build on Fedora Rawhide:

Index: dcm2niix-1.0.20220720/console/CMakeLists.txt
===================================================================
--- dcm2niix-1.0.20220720.orig/console/CMakeLists.txt
+++ dcm2niix-1.0.20220720/console/CMakeLists.txt
@@ -210,7 +210,13 @@ if(BATCH_VERSION)
     set(YAML-CPP_DIR ${YAML-CPP_DIR} CACHE PATH "Path to yaml-cpp configuration file" FORCE)
 
     find_package(YAML-CPP REQUIRED)
-    target_include_directories(dcm2niibatch PRIVATE ${YAML_CPP_INCLUDE_DIR})
+	if(YAML-CPP_FOUND AND NOT YAML_CPP_LIBRARIES)
+		# Assume yaml was found by config instead of by moudle
+		set(YAML_CPP_LIBRARIES yaml-cpp)
+	endif()
+	if(YAML_CPP_INCLUDE_DIR)
+		target_include_directories(dcm2niibatch PRIVATE ${YAML_CPP_INCLUDE_DIR})
+	endif()
     target_link_libraries(dcm2niibatch ${YAML_CPP_LIBRARIES})
 
     if(ZLIB_FOUND)

Note: Since on Fedora the headers are installed into the default directory, YAML_CPP_INCLUDE_DIR = "" so we only need to add them to the target include directories if that's not the case.

@ningfei
Copy link
Collaborator

ningfei commented Dec 18, 2022

@hobbes1069 while we can workaround this by set YAML_CPP_LIBRARIES, I believe this is a bug in yaml-cpp-devel-0.7.0-1.fc38. The variable is not set properly in /usr/lib64/cmake/yaml-cpp/yaml-cpp-config.cmake. The issue only happens on Fedora Rawhide with yaml-cpp-devel-0.7.0-1.fc38 installed. Guess it will be fixed in the upstream soon.

ningfei added a commit to ningfei/dcm2niix that referenced this issue Dec 18, 2022

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
This closes rordenlab#647.
@ningfei ningfei closed this as completed Dec 19, 2022
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

No branches or pull requests

2 participants