mirror of
https://github.com/jkriege2/JKQtPlotter.git
synced 2024-12-24 17:41:39 +08:00
improved FindCImg.cmake: now also adds proper required link libs and compile options, generates TARGET CImg:CImg
This commit is contained in:
parent
64674f4e7e
commit
2d44520b82
@ -7,10 +7,10 @@
|
||||
macro(_cimg_check_path)
|
||||
|
||||
if(EXISTS "${CIMG_INCLUDE_DIR}/CImg.h")
|
||||
set(CImg_FOUND TRUE)
|
||||
set(CIMG_FOUND TRUE)
|
||||
endif()
|
||||
|
||||
if(NOT CImg_FOUND)
|
||||
if(NOT CIMG_FOUND)
|
||||
message(STATUS "CImg include path was specified but no CImg.h file was found: ${CIMG_INCLUDE_DIR}")
|
||||
endif()
|
||||
|
||||
@ -25,12 +25,20 @@ if(NOT CIMG_INCLUDE_DIR)
|
||||
${CImg_DIR}/cimg
|
||||
${CImg_DIR}/include/cimg
|
||||
${CImg_DIR}/cimg/include
|
||||
${CIMG_DIR}
|
||||
${CIMG_DIR}/include
|
||||
${CIMG_DIR}/cimg
|
||||
${CIMG_DIR}/include/cimg
|
||||
${CIMG_DIR}/cimg/include
|
||||
${CMAKE_INSTALL_PREFIX}
|
||||
${CMAKE_INSTALL_PREFIX}/cimg
|
||||
${CMAKE_INSTALL_PREFIX}/include
|
||||
${CMAKE_INSTALL_PREFIX}/include/cimg
|
||||
${CMAKE_INSTALL_PREFIX}/cimg/include
|
||||
${KDE4_INCLUDE_DIR}
|
||||
${CIMG_PKGCONF_INCLUDE_DIRS}
|
||||
/usr/local/include
|
||||
/usr/include
|
||||
${KDE4_INCLUDE_DIR}
|
||||
${KDE4_INCLUDE_DIR}/cimg
|
||||
${KDE4_INCLUDE_DIR}/include
|
||||
${KDE4_INCLUDE_DIR}/include/cimg
|
||||
@ -43,7 +51,88 @@ if(CIMG_INCLUDE_DIR)
|
||||
_cimg_check_path()
|
||||
endif()
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(CImg DEFAULT_MSG CIMG_INCLUDE_DIR CImg_FOUND)
|
||||
|
||||
mark_as_advanced(CIMG_INCLUDE_DIR)
|
||||
if (CIMG_FOUND)
|
||||
list(APPEND CIMG_INCLUDE_DIRS
|
||||
${CIMG_INCLUDE_DIR}
|
||||
)
|
||||
|
||||
### DISPLAY :: X11 on unix-based system and GDI on windows ###
|
||||
if (UNIX OR APPLE)
|
||||
find_package (X11 QUIET) # xshm xrandr are detected as well
|
||||
if (X11_FOUND)
|
||||
set (CIMG_INCLUDE_DIRS ${CIMG_INCLUDE_DIRS} ${X11_INCLUDE_DIR} )
|
||||
set (CIMG_LIBRARIES ${CIMG_LIBRARIES} ${X11_LIBRARIES})
|
||||
message (STATUS "FindCImg.cmake: X11 found.")
|
||||
|
||||
### X11 extension :: XSHM ###
|
||||
if (X11_XShm_FOUND)
|
||||
set (CIMG_DEFINITIONS ${CIMG_DEFINITIONS} -Dcimg_use_xshm)
|
||||
message(STATUS "FindCImg.cmake: xshm found")
|
||||
else (X11_XShm_FOUND)
|
||||
message(STATUS "!!! FindCIMG.cmake !!! xshm NOT found.")
|
||||
endif (X11_XShm_FOUND)
|
||||
|
||||
### X11 extension :: XRANDR ###
|
||||
if (X11_Xrandr_FOUND)
|
||||
set (CIMG_DEFINITIONS ${CIMG_DEFINITIONS} -Dcimg_use_xrandr)
|
||||
set (CIMG_LIBRARIES ${CIMG_LIBRARIES} ${X11_Xrandr_LIB})
|
||||
message(STATUS "FindCImg.cmake: xrandr found")
|
||||
else (X11_Xrandr_FOUND)
|
||||
message(STATUS "!!! FindCIMG.cmake !!! xrandr NOT found")
|
||||
endif (X11_Xrandr_FOUND)
|
||||
|
||||
### PThread is required when using X11 display engine ###
|
||||
find_package (PTHREAD QUIET)
|
||||
if (PTHREAD_FOUND)
|
||||
set (CIMG_INCLUDE_DIRS ${CIMG_INCLUDE_DIRS} ${PTHREAD_INCLUDE_DIRS})
|
||||
set (CIMG_LIBRARIES ${CIMG_LIBRARIES} ${PTHREAD_LIBRARIES})
|
||||
message(STATUS "FindCImg.cmake: pthread found")
|
||||
else (PTHREAD_FOUND)
|
||||
message(STATUS "!!! FindCIMG.cmake !!! pthread NOT found. pthread required by cimg for running X11.")
|
||||
message(FATAL_ERROR "You need a display engine such as X11 (linux, macosx) or GDI (windows) to compile this program. Please install libs and developpement headers")
|
||||
endif (PTHREAD_FOUND)
|
||||
|
||||
else (X11_FOUND)
|
||||
message (STATUS "!!! FindCIMG.cmake !!! X11 NOT found.")
|
||||
message(WARNING "FindCImg.cmake: display disabled")
|
||||
set (CIMG_DEFINITIONS ${CIMG_DEFINITIONS} -Dcimg_display=0)
|
||||
endif (X11_FOUND)
|
||||
else (UNIX OR APPLE)
|
||||
if (WIN32)
|
||||
find_package(GDI QUIET)
|
||||
if (GDI_FOUND)
|
||||
set (CIMG_LIBRARIES ${CIMG_LIBRARIES} ${GDI_LIBRARIES})
|
||||
message(STATUS "FindCImg.cmake: GDI found")
|
||||
else (GDI_FOUND)
|
||||
message(STATUS "!!! FindCIMG.cmake !!! GDI NOT found.")
|
||||
message(WARNING "FindCImg.cmake: display disabled")
|
||||
set (CIMG_DEFINITIONS ${CIMG_DEFINITIONS} -Dcimg_display=0)
|
||||
endif (GDI_FOUND)
|
||||
endif (WIN32)
|
||||
endif (UNIX OR APPLE)
|
||||
|
||||
endif()
|
||||
|
||||
set (CIMG_INCLUDE_DIRS ${CIMG_INCLUDE_DIRS} CACHE STRING "include directories for cimg dependancies")
|
||||
set (CIMG_LIBRARIES ${CIMG_LIBRARIES} CACHE STRING "cimg required and optional 3rd party libraries")
|
||||
set (CIMG_DEFINITIONS ${CIMG_DEFINITIONS} CACHE STRING "cimg_use_xxx defines")
|
||||
set (CIMG_C_FLAGS ${CIMG_C_FLAGS} CACHE STRING "c flags for cimg")
|
||||
set (CIMG_CXX_FLAGS ${CIMG_CXX_FLAGS} CACHE STRING "c++ flags for cimg")
|
||||
|
||||
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(CImg DEFAULT_MSG CIMG_INCLUDE_DIR CIMG_FOUND)
|
||||
|
||||
mark_as_advanced(CIMG_INCLUDE_DIR)
|
||||
|
||||
if (CIMG_FOUND)
|
||||
# Library definition
|
||||
add_library(CImg::CImg INTERFACE IMPORTED)
|
||||
|
||||
target_compile_options(CImg::CImg INTERFACE ${CIMG_C_FLAGS} ${CIMG_CXX_FLAGS})
|
||||
target_compile_definitions(CImg::CImg INTERFACE ${CIMG_DEFINITIONS})
|
||||
target_link_libraries(CImg::CImg INTERFACE ${CIMG_LIBRARIES})
|
||||
target_include_directories(CImg::CImg INTERFACE ${CIMG_INCLUDE_DIRS})
|
||||
endif(CIMG_FOUND)
|
@ -20,7 +20,7 @@ if(CImg_FOUND)
|
||||
elseif(JKQtPlotter_BUILD_SHARED_LIBS)
|
||||
target_link_libraries(${EXENAME} JKQTPlotterSharedLib)
|
||||
endif()
|
||||
include_directories(${EXENAME} ${CIMG_INCLUDE_DIR} )
|
||||
target_link_libraries(${EXENAME} CImg::CImg)
|
||||
|
||||
# Installation
|
||||
install(TARGETS ${EXENAME} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||
|
@ -20,7 +20,7 @@ if(CImg_FOUND)
|
||||
elseif(JKQtPlotter_BUILD_SHARED_LIBS)
|
||||
target_link_libraries(${EXENAME} JKQTPlotterSharedLib)
|
||||
endif()
|
||||
include_directories(${EXENAME} ${CIMG_INCLUDE_DIR} )
|
||||
target_link_libraries(${EXENAME} CImg::CImg)
|
||||
|
||||
# Installation
|
||||
install(TARGETS ${EXENAME} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||
|
Loading…
Reference in New Issue
Block a user