Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save idispatch/6a6c9f398fb419672d469afa0464be95 to your computer and use it in GitHub Desktop.
Save idispatch/6a6c9f398fb419672d469afa0464be95 to your computer and use it in GitHub Desktop.
Example of CMake easy libraries
# REPLACED BY: https://github.com/eruffaldi/cmakego
# assuming to ave the correct find_package above ...
# requires CMakew 3.0 for supporting INTERFACE library type
if(ZeroMQ_FOUND)
add_library(p::zeromq INTERFACE IMPORTED)
set_property(TARGET p::zeromq PROPERTY INTERFACE_LINK_LIBRARIES ${ZeroMQ_LIBRARY})
set_property(TARGET p::zeromq PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${ZeroMQ_INCLUDE_DIR}")
endif()
if(OPENNI2_FOUND)
add_library(p::openni2 UNKNOWN IMPORTED)
set_property(TARGET p::openni2 PROPERTY IMPORTED_LOCATION ${OPENNI2_LIBRARY})
set_property(TARGET p::openni2 PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${OPENNI2_INCLUDE_DIRS}")
set_property(TARGET p::openni2 PROPERTY INTERFACE_COMPILE_DEFINITIONS "${OPENNI2_DEFINITIONS}")
endif()
if(LZ4_FOUND)
add_library(p::lz4 UNKNOWN IMPORTED)
set_property(TARGET p::lz4 PROPERTY IMPORTED_LOCATION ${LZ4_STATIC_LIB})
set_property(TARGET p::lz4 PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${LZ4_INCLUDE_DIR}")
endif()
if(GLFW_FOUND)
add_library(p::glfw INTERFACE IMPORTED)
set_property(TARGET p::glfw PROPERTY INTERFACE_LINK_LIBRARIES ${GLFW_LIBRARIES})
set_property(TARGET p::glfw PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${GLFW_INCLUDE_DIR}")
endif()
if(OPENGL_FOUND)
add_library(p::gl INTERFACE IMPORTED)
set_property(TARGET p::gl PROPERTY INTERFACE_LINK_LIBRARIES ${OPENGL_LIBRARIES})
set_property(TARGET p::gl PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${OPENGL_INCLUDE_DIR})
endif()
if(GLEW_FOUND)
add_library(p::glew UNKNOWN IMPORTED)
set_property(TARGET p::glew PROPERTY IMPORTED_LOCATION ${GLEW_LIBRARIES})
set_property(TARGET p::glew PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${GLEW_INCLUDE_DIR}")
set_property(TARGET p::glew PROPERTY INTERFACE_LINK_LIBRARIES p::gl)
endif()
if(EIGEN3_FOUND)
add_library(Eigen3 INTERFACE IMPORTED)
set_property(TARGET p::eigen3 PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${EIGEN3_INCLUDE_DIR})
endif()
if(Boost_FOUND)
add_library(p::boost INTERFACE IMPORTED)
set_property(TARGET p::boost PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${Boost_INCLUDE_DIRS})
set_property(TARGET p::boost PROPERTY INTERFACE_LINK_LIBRARIES ${Boost_LIBRARIES})
endif()
if(OpenCV_FOUND)
add_library(p::opencv INTERFACE IMPORTED)
set_property(TARGET p::opencv PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${OpenCV_INCLUDE_DIR})
set_property(TARGET p::opencv PROPERTY INTERFACE_LINK_LIBRARIES ${OpenCV_LIBS})
endif()
if(Aruco_FOUND)
add_library(p::aruco INTERFACE IMPORTED)
set_property(TARGET p::aruco PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${Aruco_INCLUDE_DIRS})
set_property(TARGET p::aruco PROPERTY INTERFACE_LINK_LIBRARIES ${Aruco_LIBRARIES} p::opencv)
endif()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment