Skip to content

Commit

Permalink
Fix/header and linkage (#54)
Browse files Browse the repository at this point in the history
* added option to build using IWYU and LWYU

* simplified examples cmake
  • Loading branch information
SalvoVirga committed Jan 14, 2019
1 parent 75c1375 commit 96433b9
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 11 deletions.
19 changes: 19 additions & 0 deletions CMakeLists.txt
Expand Up @@ -40,6 +40,25 @@ function(simple_compile_options target_name)
endif()
endfunction(simple_compile_options)

###### UTILITIES

option(SIMPLE_USE_IWYU "FALSE")
option(SIMPLE_USE_LWYU "FALSE")
mark_as_advanced(SIMPLE_USE_IWYU SIMPLE_USE_LWYU)

if (${SIMPLE_USE_IWYU})
find_program(iwyu_path NAMES include-what-you-use iwyu)
if(NOT iwyu_path)
message(FATAL_ERROR "Could not find include-what-you-use")
else()
set(CMAKE_CXX_INCLUDE_WHAT_YOU_USE ${iwyu_path})
endif()
endif()

if (${SIMPLE_USE_LWYU})
set(CMAKE_LINK_WHAT_YOU_USE ON)
endif()

###### OPTIONAL BUILDS

option(SIMPLE_BUILD_EXAMPLES "Build SIMPLE Examples" FALSE)
Expand Down
20 changes: 9 additions & 11 deletions examples/CMakeLists.txt
Expand Up @@ -4,32 +4,30 @@ project(simple_examples)
option(SIMPLE_BUILD_OPENCV_EXAMPLES "Build SIMPLE Examples that use OpenCV" FALSE)

if (${SIMPLE_BUILD_OPENCV_EXAMPLES})
find_package(OpenCV REQUIRED)
include_directories(${OpenCV_INCLUDE_DIRS})
set(LIBRARIES simple-static ${OpenCV_LIBS})
find_package(OpenCV REQUIRED COMPONENTS opencv_core opencv_videoio opencv_highgui)
add_definitions(-DDATA_DIR="${PROJECT_SOURCE_DIR}/data/")

add_executable(example_image_publisher src/example_image_publisher.cpp)
target_link_libraries(example_image_publisher ${LIBRARIES})
target_include_directories(example_image_publisher PRIVATE ${OpenCV_INCLUDE_DIRS})
target_link_libraries(example_image_publisher simple-static opencv_core opencv_videoio)

add_executable(example_image_subscriber src/example_image_subscriber.cpp)
target_link_libraries(example_image_subscriber ${LIBRARIES})
target_include_directories(example_image_subscriber PRIVATE ${OpenCV_INCLUDE_DIRS})
target_link_libraries(example_image_subscriber simple-static opencv_core opencv_highgui)

install(TARGETS example_image_publisher example_image_subscriber DESTINATION ${CMAKE_INSTALL_BINDIR})
else()
set(LIBRARIES simple-static)
endif()

add_executable(example_publisher src/example_publisher.cpp)
target_link_libraries(example_publisher ${LIBRARIES})
target_link_libraries(example_publisher simple-static)

add_executable(example_subscriber src/example_subscriber.cpp)
target_link_libraries(example_subscriber ${LIBRARIES})
target_link_libraries(example_subscriber simple-static)

add_executable(example_client src/example_client.cpp)
target_link_libraries(example_client ${LIBRARIES})
target_link_libraries(example_client simple-static)

add_executable(example_server src/example_server.cpp)
target_link_libraries(example_server ${LIBRARIES})
target_link_libraries(example_server simple-static)

install(TARGETS example_publisher example_subscriber example_client example_server DESTINATION ${CMAKE_INSTALL_BINDIR})

0 comments on commit 96433b9

Please sign in to comment.