On 29/11/2017 12:02, Johannes Zarl-Zierl wrote:
Hello Carsten,
On Samstag, 25. November 2017 11:46:44 CET Carsten Fuchs wrote:
Thanks for your reply, but how can I proceed from here?
In order to be able to write in the parent script something that works
in either case, that is,
target_link_libraries(main_program <either JPEG::JPEG or ${JPEG...} or ???>)
Well, that's one way, but that doesn't really provide any benefit above the
original solution (i.e. just define the JPEG_INCLUDES and JPEG_LIBRARIES
variables accordingly).
it seems that I either
- have to make a copy of FindJPEG.cmake, customize it to define
target JPEG::JEPG and ship it along with my project,
Either that or you define it yourself:
find_package(JPEG)
if (JPEG_FOUND)
I'd say "if(JPEG_FOUND AND NOT TARGET JPEG::JPEG)"
If someone improves FindJPEG.cmake, you won't break your build.
add_library(JPEG::JPEG UNKNOWN IMPORTED)
set_property(
TARGET JPEG::JPEG
PROPERTY IMPORTED_LOCATION ${JPEG_LIBRARIES}
)
set_property(
TARGET JPEG::JPEG PROPERTY
INTERFACE_INCLUDE_DIRECTORIES ${JPEG_INCLUDES}
)
endif()
I admit it's not a huge benefit over just using the variables. The advantages:
- you get slightly better error handling
- your target_link_libraries commands are slightly more readable.
- or write my `../ExtLibs/libjpeg/CMakeLists.txt` so that it globally
defines JPEG_LIBRARIES and JPEG_INCLUDE_DIRS
That will work, too.
Cheers,
Johannes
--
Powered by www.kitware.com
Please keep messages on-topic and check the CMake FAQ at:
http://www.cmake.org/Wiki/CMake_FAQ
Kitware offers various services to support the CMake community. For more
information on each offering, please visit:
CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake