lamyj / odil

Odil is a C++11 library for the DICOM standard
Other
85 stars 21 forks source link

ODIL_INCLUDE_DIRS not defined #78

Closed ferdymercury closed 3 years ago

ferdymercury commented 3 years ago

Before the latest commits https://github.com/lamyj/odil/commit/928da234f38c176c0b8142fa20fe1b796ab5a2d0 from September, the following was working:

find_package(Odil 0.12.0 REQUIRED)
include_directories(${ODIL_INCLUDE_DIRS})
target_link_libraries(... PUBLIC ${ODIL_LIBRARIES})

Now, however, ODIL_INCLUDE_DIRS is not defined any more, and the compilation fails as the headers are no longer found. Is there an alternative way to do this now? Maybe the README can be updated to reflect it?

Thanks for your help!

ferdymercury commented 3 years ago

In the new version, maybe something like https://cmake.org/cmake/help/v3.9/manual/cmake-packages.7.html#id16 could do the job:

file (GLOB HEADER_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/include "*.hpp")#https://stackoverflow.com/questions/275868/how-to-automatically-add-header-files-to-project

install(
  FILES
    ${HEADER_FILES}
  DESTINATION
    include
  COMPONENT
    Devel
)
lamyj commented 3 years ago

It's even simpler than this: in "modern" CMake versions, target_link_libraries can take care of everything so your CMakeLists.txt can just contain

cmake_minimum_required(VERSION 3.5)
project(test-odil-external)

cmake_policy(SET CMP0074 NEW)

find_package(Odil 0.12.0 REQUIRED)
add_executable(foo foo.cpp)
target_link_libraries(foo Odil::libodil)

(doc updated in 802c748)

ferdymercury commented 3 years ago

Great, works now, thanks!