Skip to content

Commit

Permalink
COMP: Support OpenIGTLink_* option for documentation/example/testing/…
Browse files Browse the repository at this point in the history
…gtest

This allows to include OpenIGTLink in a project using "add_subdirectory()"
by providing project specific option that will not collide with generic
option names like BUILD_* or USE_*.

The assumption is that the parent project would set the variable
OpenIGTLink_BUILD_* or OpenIGTLink_USE_* before including OpenIGTLink.
  • Loading branch information
jcfr committed Mar 22, 2018
1 parent 42872f7 commit a8c59fe
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 20 deletions.
34 changes: 22 additions & 12 deletions CMakeLists.txt
Expand Up @@ -50,22 +50,32 @@ IF(NOT OpenIGTLink_BUILD_SHARED_LIBS)
ENDIF()

#-----------------------------------------------------------------------------
OPTION(BUILD_EXAMPLES "Build OpenIGTLink example programs." OFF)
SET(OpenIGTLink_BUILD_EXAMPLES ${BUILD_EXAMPLES})
if(NOT DEFINED OpenIGTLink_BUILD_DOCUMENTATION)
option(BUILD_DOCUMENTATION "Build OpenIGTLink Documentation" OFF)
set(OpenIGTLink_BUILD_DOCUMENTATION ${BUILD_DOCUMENTATION})
endif()

#-----------------------------------------------------------------------------
OPTION(BUILD_TESTING "Build the testing tree." ON)
OPTION(USE_GTEST "Use googletest for testing" ON)
SET(OpenIGTLink_BUILD_TESTING ${BUILD_TESTING})
#link to google test library tend to fail https://github.com/openigtlink/OpenIGTLink/issues/122
IF(OpenIGTLink_BUILD_SHARED_LIBS)
SET(USE_GTEST OFF)
ENDIF()
if(NOT DEFINED OpenIGTLink_BUILD_EXAMPLES)
option(BUILD_EXAMPLES "Build OpenIGTLink example programs." OFF)
set(OpenIGTLink_BUILD_EXAMPLES ${BUILD_EXAMPLES})
endif()

#-----------------------------------------------------------------------------
OPTION(BUILD_DOCUMENTATION "Build OpenIGTLink Documentation" OFF)

if(NOT DEFINED OpenIGTLink_BUILD_TESTING)
option(BUILD_TESTING "Build the testing tree." ON)
set(OpenIGTLink_BUILD_TESTING ${BUILD_TESTING})
endif()

#-----------------------------------------------------------------------------
if(NOT DEFINED OpenIGTLink_USE_GTEST)
option(USE_GTEST "Use googletest for testing" ON)
set(OpenIGTLink_USE_GTEST ${USE_GTEST})
endif()
#link to google test library tend to fail https://github.com/openigtlink/OpenIGTLink/issues/122
IF(OpenIGTLink_BUILD_SHARED_LIBS)
SET(OpenIGTLink_USE_GTEST OFF)
ENDIF()

#-----------------------------------------------------------------------------
# Output directories.
Expand Down Expand Up @@ -282,6 +292,6 @@ ENDIF()

#-----------------------------------------------------------------------------
# Build Doxygen documentation
IF(BUILD_DOCUMENTATION)
IF(OpenIGTLink_BUILD_DOCUMENTATION)
ADD_SUBDIRECTORY(Documents/Doxygen)
ENDIF()
2 changes: 1 addition & 1 deletion Documents/Doxygen/CMakeLists.txt
@@ -1,5 +1,5 @@
#-- Add an Option to toggle the generation of the API documentation
if(BUILD_DOCUMENTATION)
if(OpenIGTLink_BUILD_DOCUMENTATION)

FIND_PACKAGE(Doxygen QUIET)
if (NOT DOXYGEN_FOUND)
Expand Down
8 changes: 4 additions & 4 deletions SuperBuild/Superbuild.cmake
Expand Up @@ -59,15 +59,15 @@ ExternalProject_Add( OpenIGTLink-lib
-DCMAKE_ARCHIVE_OUTPUT_DIRECTORY:PATH=${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}
-DBUILD_SHARED_LIBS:BOOL=${OpenIGTLink_BUILD_SHARED_LIBS}
-DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}
-DBUILD_TESTING:BOOL=${BUILD_TESTING}
-DUSE_GTEST:BOOL=${USE_GTEST}
-DOpenIGTLink_BUILD_TESTING:BOOL=${OpenIGTLink_BUILD_TESTING}
-DOpenIGTLink_USE_GTEST:BOOL=${OpenIGTLink_USE_GTEST}
-DOpenIGTLink_USE_H264:BOOL=${OpenIGTLink_USE_H264}
-DOpenIGTLink_USE_VP9:BOOL=${OpenIGTLink_USE_VP9}
-DOpenIGTLink_USE_X265:BOOL=${OpenIGTLink_USE_X265}
-DOpenIGTLink_USE_OpenHEVC:BOOL=${OpenIGTLink_USE_OpenHEVC}
-DOpenIGTLink_USE_AV1:BOOL=${OpenIGTLink_USE_AV1}
-DOpenIGTLink_USE_WEBSOCKET:BOOL=${OpenIGTLink_USE_WEBSOCKET}
-DBUILD_EXAMPLES:BOOL=${BUILD_EXAMPLES}
-DOpenIGTLink_BUILD_EXAMPLES:BOOL=${OpenIGTLink_BUILD_EXAMPLES}
-DCMAKE_CXX_FLAGS:STRING=${CMAKE_CXX_FLAGS}
-DCMAKE_C_FLAGS:STRING=${CMAKE_C_FLAGS}
-DOpenH264_INCLUDE_DIR:STRING=${OpenH264_INCLUDE_DIR}
Expand All @@ -86,4 +86,4 @@ ExternalProject_Add( OpenIGTLink-lib
#--Install step-----------------
INSTALL_COMMAND ""
DEPENDS ${OpenIGTLink_DEPENDENCIES}
)
)
4 changes: 2 additions & 2 deletions Testing/CMakeLists.txt
Expand Up @@ -9,7 +9,7 @@ include_directories(${PROJECT_BINARY_DIR})
configure_file(${PROJECT_SOURCE_DIR}/igtlTestConfig.h.in ${PROJECT_BINARY_DIR}/igtlTestConfig.h)
ENABLE_TESTING()
ADD_SUBDIRECTORY( igtlutil )
IF(USE_GTEST AND (NOT OpenIGTLink_BUILD_SHARED_LIBS))
IF(OpenIGTLink_USE_GTEST AND (NOT OpenIGTLink_BUILD_SHARED_LIBS))
#-----------
#download of GoogleTest
if( MSVC ) # VS2012 doesn't support correctly the tuples yet
Expand Down Expand Up @@ -87,7 +87,7 @@ IF(${OpenIGTLink_PROTOCOL_VERSION} GREATER "2" AND (OpenIGTLink_USE_H264 OR Open
ENDIF()


IF(USE_GTEST AND (NOT OpenIGTLink_BUILD_SHARED_LIBS))
IF(OpenIGTLink_USE_GTEST AND (NOT OpenIGTLink_BUILD_SHARED_LIBS))
SET(GTEST_LINK OpenIGTLink gtest_main gtest gmock_main gmock)
ELSE()
SET(GTEST_LINK OpenIGTLink)
Expand Down
4 changes: 3 additions & 1 deletion Testing/igtlTestConfig.h.in
Expand Up @@ -20,7 +20,9 @@
// we will switch entirely to the GTest.
//

#if defined(USE_GTEST)
#cmakedefine OpenIGTLink_USE_GTEST

#if defined(OpenIGTLink_USE_GTEST)
#include "gtest/gtest.h"
#include "gmock/gmock.h"
#else
Expand Down

0 comments on commit a8c59fe

Please sign in to comment.