From 269c68b43d1b2f52657a99f685ff1f278648ffd2 Mon Sep 17 00:00:00 2001 From: Longquan Chen Date: Mon, 22 Jan 2018 11:25:29 -0500 Subject: [PATCH] EHN: VP9 download and link for Visual studio 2013 and 2015. build of openigtlink use the other compilers in windows platform will still succeed, but without vp9 support. --- BUILD.md | 9 ++- CMakeLists.txt | 10 +-- Examples/VideoStreaming/VideoServer.cxx | 39 ++++++++++- OpenIGTLinkConfig.cmake.in | 2 +- Source/VideoStreaming/igtlVP9Decoder.h | 10 +-- Source/VideoStreaming/igtlVP9Encoder.h | 4 +- .../VideoStreaming/igtlVideoStreaming.cmake | 18 ++++-- Source/igtlGeneralSocket.h | 5 ++ Source/igtlMessageFactory.cxx | 4 +- Source/igtlMessageRTPWrapper.h | 5 -- SuperBuild/External_VP9.cmake | 40 +++++++----- SuperBuild/External_yasm.cmake | 8 ++- SuperBuild/FindVP9.cmake | 60 ++++++++--------- Testing/CMakeLists.txt | 64 +++++++++---------- Testing/igtlTestConfig.h.in | 3 +- appveyor.yml | 10 ++- igtlConfigure.h.in | 2 +- 17 files changed, 170 insertions(+), 123 deletions(-) diff --git a/BUILD.md b/BUILD.md index bb0642d6..04271bf4 100644 --- a/BUILD.md +++ b/BUILD.md @@ -48,7 +48,7 @@ If all went OK you will have the executable and the library: VideoStreaming --------------- -You might want to use OpenIGTLink library to perform video streaming. Currently OpenH264, H265 and VP9 are supported in the OpenIGTLink. +You might want to use OpenIGTLink library to perform video streaming. Currently OpenH264, H265, VP9 and AV1 are supported in the OpenIGTLink. * Prerequisites @@ -64,6 +64,7 @@ In the case of H265 build, H265 have many implementations, the encoder used in l OpenIGTLink library doesn't build H265 libraries, so the users need to download and compile the libraries by themselves. Afterwards, set the variables-"X265_INCLUDE_DIR, X265_LIBRARY_DIR, OPENHEVC_INCLUDE_DIR, OpenHEVC_LIBRARY"-correctly in cmake configuration. +In the case of AV1 build, the AV1 codec is cmakefied. Once the OpenIGTLink_USE_AV1 option is selected, the openigtlink libray will superbuild the codec and link automatically. * Linux / Mac OS X In the case of Linux and Mac, after installing the required program in the Prerequisites section, @@ -84,7 +85,6 @@ $ make * Windows Build In the case of windows build, please refer to the following websites for H264, X265 and VP9 respectively. -Make sure the build are 32 bit. Useful H264 build instructions: https://github.com/cisco/openh264 @@ -94,6 +94,11 @@ Useful VP9 build instructions: https://www.webmproject.org/code/build-prerequisites/ http://wiki.webmproject.org/ffmpeg/building-with-libvpx +OpenIGTLink provides binary library files for visual studio 12 2013 and visual studio 14 2015. +The libray will be automatically downloaded during the project build when user configure OpenIGTLink library using these cmake generators: +"Visual Studio 12 2013", "Visual Studio 12 2013 Win64", "Visual Studio 14 2015" and "Visual Studio 14 2015 Win64". +For the rest cmake generators, the user need to provide the VP9_INCLUDE_DIR and VP9_BINARY_DIR, otherwize the video streaming feature will be deactivated. + Useful X265 build intructions: https://bitbucket.org/multicoreware/x265/wiki/CrossCompile diff --git a/CMakeLists.txt b/CMakeLists.txt index 223984f4..212bd659 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -57,9 +57,9 @@ SET(OpenIGTLink_BUILD_EXAMPLES ${BUILD_EXAMPLES}) OPTION(BUILD_TESTING "Build the testing tree." ON) OPTION(USE_GTEST "Use googletest for testing" ON) SET(OpenIGTLink_BUILD_TESTING ${BUILD_TESTING}) -SET(OpenIGTLink_USE_GTEST "0") -IF(USE_GTEST) - SET(OpenIGTLink_USE_GTEST "1") +#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() #----------------------------------------------------------------------------- @@ -165,10 +165,10 @@ IF(CMAKE_USE_PTHREADS) ENDIF() ENDIF() -SET(OpenIGTLink_ENABLE_VIDEOSTREAMING "0") +OPTION(OpenIGTLink_ENABLE_VIDEOSTREAMING "Video stream feature activated." OFF) IF(${OpenIGTLink_PROTOCOL_VERSION} GREATER "2") IF (OpenIGTLink_USE_H264 OR OpenIGTLink_USE_VP9 OR OpenIGTLink_USE_X265 OR OpenIGTLink_USE_OpenHEVC OR OpenIGTLink_USE_AV1) - SET(OpenIGTLink_ENABLE_VIDEOSTREAMING "1") + SET(OpenIGTLink_ENABLE_VIDEOSTREAMING ON) ENDIF() ENDIF() #----------------------------------------------------------------------------- diff --git a/Examples/VideoStreaming/VideoServer.cxx b/Examples/VideoStreaming/VideoServer.cxx index dadb07b7..741f9c10 100644 --- a/Examples/VideoStreaming/VideoServer.cxx +++ b/Examples/VideoStreaming/VideoServer.cxx @@ -49,7 +49,7 @@ int Width = 256; int Height = 256; std::string testFileName(OpenIGTLink_SOURCE_ROOTDIR); int startIndex = 0; -int inputFrameNum = 500; +int inputFrameNum = 2000; void* ThreadFunction(void* ptr); @@ -103,11 +103,41 @@ int main(int argc, char* argv[]) { std::cerr << "A client is connected." << std::endl; // Create a message buffer to receive header - td.interval = 30; + td.interval = 100; td.glock = glock; td.socket = socket; td.stop = 0; threadID = threader->SpawnThread((igtl::ThreadFunctionType) &ThreadFunction, &td); + // Create a message buffer to receive header + igtl::MessageHeader::Pointer headerMsg; + headerMsg = igtl::MessageHeader::New(); + //------------------------------------------------------------ + // loop + for (;;) + { + // Initialize receive buffer + headerMsg->InitPack(); + + // Receive generic header from the socket + int rs = socket->Receive(headerMsg->GetPackPointer(), headerMsg->GetPackSize()); + if (rs == 0) + { + if (threadID >= 0) + { + td.stop = 1; + threader->TerminateThread(threadID); + threadID = -1; + } + std::cerr << "Disconnecting the client." << std::endl; + td.socket = NULL; // VERY IMPORTANT. Completely remove the instance. + socket->CloseSocket(); + break; + } + if (rs != headerMsg->GetPackSize()) + { + continue; + } + } } } @@ -141,6 +171,7 @@ void* ThreadFunction(void * ptr) VP9StreamEncoder->SetPicWidthAndHeight(Width,Height); VP9StreamEncoder->InitializeEncoder(); VP9StreamEncoder->SetLosslessLink(true); + VP9StreamEncoder->SetKeyFrameDistance(50); encoder = VP9StreamEncoder; #elif defined(OpenIGTLink_USE_AV1) igtlAV1Encoder* AV1StreamEncoder = new igtlAV1Encoder(); @@ -173,6 +204,10 @@ void* ThreadFunction(void * ptr) memset(pDecodedPic->data[0], 0, Width * Height * 3 / 2); for(int i = 0; i stop) + { + break; + } std::string sep = "/"; #if defined(_WIN32) || defined(_WIN64) sep = "\\"; diff --git a/OpenIGTLinkConfig.cmake.in b/OpenIGTLinkConfig.cmake.in index ab03211b..309f5a9f 100644 --- a/OpenIGTLinkConfig.cmake.in +++ b/OpenIGTLinkConfig.cmake.in @@ -45,7 +45,7 @@ SET(OpenIGTLink_USE_VP9 @OpenIGTLink_USE_VP9@) SET(OpenIGTLink_USE_X265 @OpenIGTLink_USE_X265@) SET(OpenIGTLink_USE_OpenHEVC @OpenIGTLink_USE_OpenHEVC@) SET(OpenIGTLink_USE_AV1 @OpenIGTLink_USE_AV1@) -SET(OpenIGTLink_ENABLE_VIDEOSTREAMING "@OpenIGTLink_ENABLE_VIDEOSTREAMING@") +SET(OpenIGTLink_ENABLE_VIDEOSTREAMING @OpenIGTLink_ENABLE_VIDEOSTREAMING@) SET(OpenIGTLink_USE_WEBSOCKET @OpenIGTLink_USE_WEBSOCKET@) # Path to CableSwig configuration used by OpenIGTLink. diff --git a/Source/VideoStreaming/igtlVP9Decoder.h b/Source/VideoStreaming/igtlVP9Decoder.h index 5f188f77..ee4b0b10 100644 --- a/Source/VideoStreaming/igtlVP9Decoder.h +++ b/Source/VideoStreaming/igtlVP9Decoder.h @@ -30,12 +30,12 @@ #include "igtl_types.h" #include "igtlVideoMessage.h" #include "igtlCodecCommonClasses.h" -#include "vpx/vpx_decoder.h" +#include "vpx_decoder.h" #include "vpx_config.h" -#include "vpx/vp8dx.h" -#include "vpx/vpx_codec.h" -#include "vpx/vpx_image.h" -#include "vpx/vpx_integer.h" +#include "vp8dx.h" +#include "vpx_codec.h" +#include "vpx_image.h" +#include "vpx_integer.h" namespace igtl { diff --git a/Source/VideoStreaming/igtlVP9Encoder.h b/Source/VideoStreaming/igtlVP9Encoder.h index b0d91c27..fae3c667 100644 --- a/Source/VideoStreaming/igtlVP9Encoder.h +++ b/Source/VideoStreaming/igtlVP9Encoder.h @@ -17,8 +17,8 @@ #include #include -#include "vpx/vp8cx.h" -#include "vpx/vpx_image.h" +#include "vp8cx.h" +#include "vpx_image.h" #include "igtlCodecCommonClasses.h" #include "igtl_header.h" diff --git a/Source/VideoStreaming/igtlVideoStreaming.cmake b/Source/VideoStreaming/igtlVideoStreaming.cmake index 324f206f..55ef24d8 100644 --- a/Source/VideoStreaming/igtlVideoStreaming.cmake +++ b/Source/VideoStreaming/igtlVideoStreaming.cmake @@ -40,7 +40,7 @@ IF(OpenIGTLink_USE_H264) ENDIF() IF(OpenIGTLink_USE_VP9) INCLUDE(${OpenIGTLink_SOURCE_DIR}/SuperBuild/External_VP9.cmake) - IF(EXISTS ${VP9_LIBRARY_DIR}) + IF((NOT "${VP9_LIBRARY_DIR}" STREQUAL "") AND (NOT "${VP9_INCLUDE_DIR}" STREQUAL "")) LIST(APPEND OpenIGTLink_INCLUDE_DIRS ${VP9_INCLUDE_DIR} ) @@ -52,11 +52,9 @@ IF(OpenIGTLink_USE_VP9) ${PROJECT_SOURCE_DIR}/Source/VideoStreaming/igtlVP9Decoder.h ${PROJECT_SOURCE_DIR}/Source/VideoStreaming/igtlVP9Encoder.h ) - IF(NOT ${VP9_LIBRARY_DIR} EQUAL "") - LIST(APPEND OpenIGTLink_INCLUDE_DIRS - "${VP9_LIBRARY_DIR}" ) - LINK_DIRECTORIES("${VP9_LIBRARY_DIR}/lib") - ENDIF() + LIST(APPEND OpenIGTLink_INCLUDE_DIRS + ${VP9_LIBRARY_DIR} ) + LINK_DIRECTORIES("${VP9_LIBRARY_DIR}/lib") ELSE() MESSAGE("VP9_INCLUDE_DIR or VP9_LIBRARY_DIR no found") ENDIF() @@ -113,8 +111,14 @@ IF(WIN32) # for Windows ENDIF() IF(OpenIGTLink_USE_VP9) #To do, library name depends on the compiler setting, could be vpxmt.lib and vpxmtd also. Make sure the setting matches. + #SET(VP9_lib optimized ${VP9_LIBRARY_DIR}\\Release\\vpxmd.lib debug ${VP9_LIBRARY_DIR}\\Debug\\vpxmdd.lib) + if("${CMAKE_GENERATOR}" MATCHES "(Win64|IA64)") + SET(VP9_lib optimized ${VP9_LIBRARY_DIR}\\x64\\Release\\vpxmd.lib debug ${VP9_LIBRARY_DIR}\\x64\\Debug\\vpxmdd.lib) + else() + SET(VP9_lib optimized ${VP9_LIBRARY_DIR}\\Win32\\Release\\vpxmd.lib debug ${VP9_LIBRARY_DIR}\\Win32\\Debug\\vpxmdd.lib) + endif() LIST(APPEND LINK_LIBS - VP9_lib + ${VP9_lib} ) ENDIF() IF(OpenIGTLink_USE_X265) diff --git a/Source/igtlGeneralSocket.h b/Source/igtlGeneralSocket.h index ccc4c71a..b46a44d2 100755 --- a/Source/igtlGeneralSocket.h +++ b/Source/igtlGeneralSocket.h @@ -46,6 +46,11 @@ #include "igtlWin32Header.h" #include "igtl_types.h" +#if defined(_WIN32) && !defined(__CYGWIN__) +#else +#include +#endif + #define IP4AddressStrLen 16 #define IP6AddressStrLen 46 diff --git a/Source/igtlMessageFactory.cxx b/Source/igtlMessageFactory.cxx index c504bf15..b0030842 100644 --- a/Source/igtlMessageFactory.cxx +++ b/Source/igtlMessageFactory.cxx @@ -36,7 +36,7 @@ PURPOSE. See the above copyright notices for more information. #include "igtlCommandMessage.h" #endif // OpenIGTLink_PROTOCOL_VERSION >= 3 -#if OpenIGTLink_ENABLE_VIDEOSTREAMING +#if defined(OpenIGTLink_ENABLE_VIDEOSTREAMING) #include "igtlVideoMessage.h" #endif @@ -92,7 +92,7 @@ MessageFactory::MessageFactory() this->AddMessageType("RTS_COMMAND", (PointerToMessageBaseNew)&igtl::RTSCommandMessage::New); #endif -#if OpenIGTLink_ENABLE_VIDEOSTREAMING +#if defined(OpenIGTLink_ENABLE_VIDEOSTREAMING) this->AddMessageType("VIDEO", (PointerToMessageBaseNew)&igtl::VideoMessage::New); #endif } diff --git a/Source/igtlMessageRTPWrapper.h b/Source/igtlMessageRTPWrapper.h index dd33bf52..618bad45 100755 --- a/Source/igtlMessageRTPWrapper.h +++ b/Source/igtlMessageRTPWrapper.h @@ -30,11 +30,6 @@ #include "igtlTimeStamp.h" #include "igtlOSUtil.h" -#if defined(WIN32) || defined(_WIN32) -#include -#else -#include -#endif /// This number defines the maximum number for UDP packet buffering, to avoid overflow of the buffer, the first buffered packet will be #define PacketMaximumBufferNum 1000 diff --git a/SuperBuild/External_VP9.cmake b/SuperBuild/External_VP9.cmake index 43bcb39a..aeeeabbf 100644 --- a/SuperBuild/External_VP9.cmake +++ b/SuperBuild/External_VP9.cmake @@ -20,7 +20,7 @@ ELSE() # OpenIGTLink has not been built yet, so download and build it as an external project MESSAGE(STATUS "Downloading VP9 from https://github.com/webmproject/libvpx.git") if(NOT CMAKE_SYSTEM_NAME STREQUAL "Windows") - SET (VP9_INCLUDE_DIR "${CMAKE_BINARY_DIR}/Deps/VP9" CACHE PATH "VP9 source directory" FORCE) + SET (VP9_INCLUDE_DIR "${CMAKE_BINARY_DIR}/Deps/VP9/vpx" CACHE PATH "VP9 source directory" FORCE) SET (VP9_LIBRARY_DIR "${CMAKE_BINARY_DIR}/Deps/VP9" CACHE PATH "VP9 library directory" FORCE) ExternalProject_Add(VP9 PREFIX "${CMAKE_BINARY_DIR}/Deps/VP9-prefix" @@ -36,32 +36,38 @@ ELSE() DEPENDS ${VP9_DEPENDENCIES} ) else() - if("${CMAKE_GENERATOR}" STREQUAL "Visual Studio 14 2015") - SET (VP9_INCLUDE_DIR "${CMAKE_BINARY_DIR}/Deps/VP9" CACHE PATH "VP9 source directory" FORCE) - SET (VP9_LIBRARY_DIR "${CMAKE_BINARY_DIR}/Deps/VP9-Binary/VP9" CACHE PATH "VP9 library directory" FORCE) - ExternalProject_Add(VP9-Source - GIT_REPOSITORY https://github.com/webmproject/libvpx/ - GIT_TAG v1.6.1 - SOURCE_DIR "${CMAKE_BINARY_DIR}/Deps/VP9" - CONFIGURE_COMMAND "" - BUILD_ALWAYS 0 - BUILD_COMMAND "" - INSTALL_COMMAND "" - TEST_COMMAND "" - ) + if( ("${CMAKE_GENERATOR}" STREQUAL "Visual Studio 14 2015") OR ("${CMAKE_GENERATOR}" STREQUAL "Visual Studio 14 2015 Win64" ) OR + ("${CMAKE_GENERATOR}" STREQUAL "Visual Studio 12 2013") OR ("${CMAKE_GENERATOR}" STREQUAL "Visual Studio 12 2013 Win64" ) + ) + SET (VP9_INCLUDE_DIR "${CMAKE_BINARY_DIR}/Deps/VP9-Binary/vpx" CACHE PATH "VP9 source directory" FORCE) + SET (BinaryURL "") + if ("${CMAKE_GENERATOR}" STREQUAL "Visual Studio 14 2015") + SET (VP9_LIBRARY_DIR "${CMAKE_BINARY_DIR}/Deps/VP9-Binary/VP9-vs14" CACHE PATH "VP9 library directory" FORCE) + SET (BinaryURL "https://github.com/openigtlink/CodecLibrariesFile/archive/vs14.zip") + elseif("${CMAKE_GENERATOR}" STREQUAL "Visual Studio 14 2015 Win64" ) + SET (VP9_LIBRARY_DIR "${CMAKE_BINARY_DIR}/Deps/VP9-Binary/VP9-vs14-Win64" CACHE PATH "VP9 library directory" FORCE) + SET (BinaryURL "https://github.com/openigtlink/CodecLibrariesFile/archive/vs14-Win64.zip") + elseif ("${CMAKE_GENERATOR}" STREQUAL "Visual Studio 12 2013") + SET (VP9_LIBRARY_DIR "${CMAKE_BINARY_DIR}/Deps/VP9-Binary/VP9-vs12" CACHE PATH "VP9 library directory" FORCE) + SET (BinaryURL "https://github.com/openigtlink/CodecLibrariesFile/archive/vs12.zip") + elseif("${CMAKE_GENERATOR}" STREQUAL "Visual Studio 12 2013 Win64" ) + SET (VP9_LIBRARY_DIR "${CMAKE_BINARY_DIR}/Deps/VP9-Binary/VP9-vs12-Win64" CACHE PATH "VP9 library directory" FORCE) + SET (BinaryURL "https://github.com/openigtlink/CodecLibrariesFile/archive/vs12-Win64.zip") + endif() ExternalProject_Add(VP9 - GIT_REPOSITORY https://github.com/openigtlink/CodecLibrariesFile.git - GIT_TAG master + URL ${BinaryURL} SOURCE_DIR "${CMAKE_BINARY_DIR}/Deps/VP9-Binary" CONFIGURE_COMMAND "" BUILD_ALWAYS 0 BUILD_COMMAND "" INSTALL_COMMAND "" TEST_COMMAND "" - DEPENDS VP9-Source ) else() SET(OpenIGTLink_USE_VP9 OFF CACHE BOOL "" FORCE) + IF (OpenIGTLink_USE_H264 OR OpenIGTLink_USE_VP9 OR OpenIGTLink_USE_X265 OR OpenIGTLink_USE_OpenHEVC OR OpenIGTLink_USE_AV1) + SET(OpenIGTLink_ENABLE_VIDEOSTREAMING OFF) + ENDIF() message(WARNING "Only support for Visual Studio 14 2015") endif() endif() diff --git a/SuperBuild/External_yasm.cmake b/SuperBuild/External_yasm.cmake index 0faee77c..d1f8dee1 100644 --- a/SuperBuild/External_yasm.cmake +++ b/SuperBuild/External_yasm.cmake @@ -3,11 +3,15 @@ include(${CMAKE_ROOT}/Modules/ExternalProject.cmake) include(${OpenIGTLink_SOURCE_DIR}/SuperBuild/FindYASM.cmake) include(${CMAKE_ROOT}/Modules/FindPythonInterp.cmake) -find_package(PythonInterp "2.7" REQUIRED) IF(YASM_FOUND) # YASM has been built already MESSAGE(STATUS "Using YASM available at: ${YASM_BINARY_DIR}") ELSE() + SET(YASM_PYTHON_EXECUTABLE "" CACHE STRING "Python Interpreter") + if("${YASM_PYTHON_EXECUTABLE}" STREQUAL "") + find_package(PythonInterp "2.7" REQUIRED) + SET(YASM_PYTHON_EXECUTABLE ${PYTHON_EXECUTABLE}) + endif() # yas has not been built yet, so download and build it as an external project SET(GIT_REPOSITORY "https://github.com/yasm/yasm.git") SET(GIT_TAG "master") @@ -35,7 +39,7 @@ ELSE() -DCMAKE_LIBRARY_OUTPUT_DIRECTORY:STRING=${YASM_BINARY_DIR} -DCMAKE_RUNTIME_OUTPUT_DIRECTORY:STRING=${YASM_BINARY_DIR} -DYASM_INSTALL_BIN_DIR:STRING="bin" - -DPYTHON_EXECUTABLE:STRING=${PYTHON_EXECUTABLE} + -DPYTHON_EXECUTABLE:STRING=${YASM_PYTHON_EXECUTABLE} -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY:PATH=${YASM_BINARY_DIR} -DBUILD_SHARED_LIBS:BOOL=${OpenIGTLink_BUILD_SHARED_LIBS} -DBUILD_TESTING:BOOL=OFF diff --git a/SuperBuild/FindVP9.cmake b/SuperBuild/FindVP9.cmake index 61b5f760..45ccc009 100644 --- a/SuperBuild/FindVP9.cmake +++ b/SuperBuild/FindVP9.cmake @@ -6,7 +6,6 @@ # VP9_FOUND - found VP9 # VP9_INCLUDE_DIR - the VP9 include directory # VP9_LIBRARY_DIR - VP9 library directory - if(NOT CMAKE_SYSTEM_NAME STREQUAL "Windows") SET( VP9_PATH_HINTS ${VP9_ROOT} @@ -25,49 +24,42 @@ if(NOT CMAKE_SYSTEM_NAME STREQUAL "Windows") PATH_SUFFIXES ${Platform}/${CMAKE_BUILD_TYPE} HINTS ${VP9_PATH_HINTS} ) - include(FindPackageHandleStandardArgs) - FIND_PACKAGE_HANDLE_STANDARD_ARGS(VP9 REQUIRED_VARS VP9_LIBRARY_DIR VP9_INCLUDE_DIR) - - mark_as_advanced(VP9_INCLUDE_DIR VP9_LIBRARY_DIR) else() SET(VP9_PATH_HINTS ${VP9_ROOT} ${VP9_INCLUDE_DIR} ) - - unset(VP9_INCLUDE_DIR CACHE) - find_path(VP9_INCLUDE_DIR NAMES vp8cx.h vpx_image.h + find_path(VP9_INCLUDE_DIRECT_DIR NAMES vp8cx.h vpx_image.h PATH_SUFFIXES vpx HINTS ${VP9_PATH_HINTS} - ) - if((NOT VP9_INCLUDE_DIR) AND (NOT "${CMAKE_GENERATOR}" STREQUAL "Visual Studio 14 2015" )) - MESSAGE(FATAL_ERROR "VP9 include files not found, specify the file path") - endif() - - set(VP9_LIBRARY_DIR "" CACHE PATH "") + ) SET(VP9_PATH_HINTS - ${VP9_ROOT} - ${VP9_LIBRARY_DIR}/Win32/Release - ${VP9_LIBRARY_DIR}/Win32/Debug - ${VP9_LIBRARY_DIR}/x64/Release - ${VP9_LIBRARY_DIR}/x64/Debug + ${VP9_ROOT} ) - + + if("${CMAKE_GENERATOR}" MATCHES "(Win64|IA64)") + list(APPEND VP9_PATH_HINTS ${VP9_LIBRARY_DIR}/x64/Release ${VP9_LIBRARY_DIR}/x64/Debug) + else() + list(APPEND VP9_PATH_HINTS ${VP9_LIBRARY_DIR}/Win32/Release ${VP9_LIBRARY_DIR}/Win32/Debug) + endif() find_path(VP9_LIBRARY_DIRECT_DIR vpxmdd.lib | vpxmd.lib - HINTS ${VP9_PATH_HINTS} - ) - if(VP9_LIBRARY_DIRECT_DIR OR ("${CMAKE_GENERATOR}" STREQUAL "Visual Studio 14 2015")) - unset(VP9_LIBRARY_DIRECT_DIR CACHE) - add_library(VP9_lib STATIC IMPORTED GLOBAL) - if(NOT "${CMAKE_GENERATOR}" MATCHES "(Win64|IA64)") - set_property(TARGET VP9_lib PROPERTY IMPORTED_LOCATION_RELEASE ${VP9_LIBRARY_DIR}/Win32/Release/vpxmd.lib) - set_property(TARGET VP9_lib PROPERTY IMPORTED_LOCATION_DEBUG ${VP9_LIBRARY_DIR}/Win32/Debug/vpxmdd.lib) - else() - set_property(TARGET VP9_lib PROPERTY IMPORTED_LOCATION_RELEASE ${VP9_LIBRARY_DIR}/x64/Release/vpxmd.lib) - set_property(TARGET VP9_lib PROPERTY IMPORTED_LOCATION_DEBUG ${VP9_LIBRARY_DIR}/x64/Debug/vpxmdd.lib) - endif() - else() + HINTS ${VP9_PATH_HINTS} + ) + if(VP9_LIBRARY_DIRECT_DIR AND VP9_INCLUDE_DIRECT_DIR) + #VP9 library and header files are all found + SET(VP9_INCLUDE_DIR "${VP9_INCLUDE_DIRECT_DIR}" CACHE PATH "" FORCE) + unset(VP9_LIBRARY_DIRECT_DIR CACHE) + unset(VP9_INCLUDE_DIRECT_DIR CACHE) + else() + unset(VP9_INCLUDE_DIRECT_DIR CACHE) unset(VP9_LIBRARY_DIRECT_DIR CACHE) # don't expose the VP9_LIBRARY_DIRECT_DIR to user, force the user to set the variable VP9_LIBRARY_DIR - MESSAGE(FATAL_ERROR "VP9 library file not found, specify the path where the vp9 project was build, if vp9 was built in source, then set the library path the same as include path") + MESSAGE(WARNING "VP9 library file not found, specify the path where the vp9 project was build, if vp9 was built in source, then set the library path the same as include path") + SET(VP9_LIBRARY_DIR "" CACHE PATH "" FORCE) + SET(VP9_INCLUDE_DIR "" CACHE PATH "" FORCE) endif() endif() + +include(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(VP9 REQUIRED_VARS VP9_LIBRARY_DIR VP9_INCLUDE_DIR) +mark_as_advanced(VP9_INCLUDE_DIR VP9_LIBRARY_DIR) + \ No newline at end of file diff --git a/Testing/CMakeLists.txt b/Testing/CMakeLists.txt index 2a154b8f..63449115 100644 --- a/Testing/CMakeLists.txt +++ b/Testing/CMakeLists.txt @@ -6,41 +6,39 @@ include(${OpenIGTLink_USE_FILE}) include_directories(${OpenIGTLink_INCLUDE_DIRS}) link_directories(${OpenIGTLink_LIBRARY_DIRS}) include_directories(${PROJECT_BINARY_DIR}) -OPTION(USE_GTEST "Build the testing tree." ON) configure_file(${PROJECT_SOURCE_DIR}/igtlTestConfig.h.in ${PROJECT_BINARY_DIR}/igtlTestConfig.h) ENABLE_TESTING() ADD_SUBDIRECTORY( igtlutil ) -IF(USE_GTEST) - #----------- - #download of GoogleTest - if( MSVC ) # VS2012 doesn't support correctly the tuples yet - add_definitions("-D_VARIADIC_MAX=10") - endif() - # Download and unpack googletest at configure time - configure_file(GoogletestDownload.txt.in - googletest-download/CMakeLists.txt) - execute_process(COMMAND "${CMAKE_COMMAND}" -G "${CMAKE_GENERATOR}" . - WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/googletest-download" ) - - execute_process(COMMAND "${CMAKE_COMMAND}" --build . - WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/googletest-download" ) - - # Prevent GoogleTest from overriding our compiler/linker options - # when building with Visual Studio - set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) - - # Add googletest directly to our build. This adds - # the following targets: gtest, gtest_main, gmock - # and gmock_main - add_subdirectory("${PROJECT_BINARY_DIR}/gmock" - "${PROJECT_BINARY_DIR}/gmock-build" ) - - # The gtest/gmock targets carry header search path - # dependencies automatically when using CMake 2.8.11 or - # later. Otherwise we have to add them here ourselves. - include_directories("${gtest_SOURCE_DIR}/include") - include_directories("${gmock_SOURCE_DIR}/include") -#--------------- +IF(USE_GTEST AND (NOT OpenIGTLink_BUILD_SHARED_LIBS)) + #----------- + #download of GoogleTest + if( MSVC ) # VS2012 doesn't support correctly the tuples yet + add_definitions("-D_VARIADIC_MAX=10") + endif() + # Download and unpack googletest at configure time + configure_file(GoogletestDownload.txt.in + googletest-download/CMakeLists.txt) + execute_process(COMMAND "${CMAKE_COMMAND}" -G "${CMAKE_GENERATOR}" . + WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/googletest-download" ) + + execute_process(COMMAND "${CMAKE_COMMAND}" --build . + WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/googletest-download" ) + + # Prevent GoogleTest from overriding our compiler/linker options + # when building with Visual Studio + set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) + + # Add googletest directly to our build. This adds + # the following targets: gtest, gtest_main, gmock + # and gmock_main + add_subdirectory("${PROJECT_BINARY_DIR}/gmock" + "${PROJECT_BINARY_DIR}/gmock-build" ) + + # The gtest/gmock targets carry header search path + # dependencies automatically when using CMake 2.8.11 or + # later. Otherwise we have to add them here ourselves. + include_directories("${gtest_SOURCE_DIR}/include") + include_directories("${gmock_SOURCE_DIR}/include") ENDIF() ADD_EXECUTABLE(igtlMultiThreaderTest1 igtlMultiThreaderTest1.cxx) @@ -89,7 +87,7 @@ IF(${OpenIGTLink_PROTOCOL_VERSION} GREATER "2" AND (OpenIGTLink_USE_H264 OR Open ENDIF() -IF(USE_GTEST) +IF(USE_GTEST AND (NOT OpenIGTLink_BUILD_SHARED_LIBS)) SET(GTEST_LINK OpenIGTLink gtest_main gtest gmock_main gmock) ELSE() SET(GTEST_LINK OpenIGTLink) diff --git a/Testing/igtlTestConfig.h.in b/Testing/igtlTestConfig.h.in index a5e0d008..7fbc515d 100644 --- a/Testing/igtlTestConfig.h.in +++ b/Testing/igtlTestConfig.h.in @@ -20,8 +20,7 @@ // we will switch entirely to the GTest. // -#define OpenIGTLink_USE_GTEST @OpenIGTLink_USE_GTEST@ -#if OpenIGTLink_USE_GTEST == 1 +#if defined(USE_GTEST) #include "gtest/gtest.h" #include "gmock/gmock.h" #else diff --git a/appveyor.yml b/appveyor.yml index 979ba0c0..3e4bbd3d 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -5,9 +5,12 @@ os: Visual Studio 2015 #Google Test is not build correctly for v120 and v110, but the TestConfigure.h file is a workaround solution for the testing environment: matrix: - - Toolset: v110 - - Toolset: v120 + - Toolset: v140-64 - Toolset: v140 + - Toolset: v120-64 + - Toolset: v120 + - Toolset: v110 + platform: - x86 @@ -15,7 +18,6 @@ platform: - ARM configuration: - - Debug - Release @@ -39,7 +41,9 @@ before_build: { "v110" {"Visual Studio 11 2012"} "v120" {"Visual Studio 12 2013"} + "v120-64" {"Visual Studio 12 2013 Win64"} "v140" {"Visual Studio 14 2015"} + "v140-64" {"Visual Studio 14 2015 Win64"} } build_script: diff --git a/igtlConfigure.h.in b/igtlConfigure.h.in index 3919e342..09f1f9dc 100644 --- a/igtlConfigure.h.in +++ b/igtlConfigure.h.in @@ -42,7 +42,7 @@ #cmakedefine OpenIGTLink_USE_OpenHEVC #cmakedefine OpenIGTLink_USE_AV1 #cmakedefine OpenIGTLink_USE_WEBSOCKET -#define OpenIGTLink_ENABLE_VIDEOSTREAMING @OpenIGTLink_ENABLE_VIDEOSTREAMING@ +#cmakedefine OpenIGTLink_ENABLE_VIDEOSTREAMING #define OpenIGTLink_PROTOCOL_VERSION_1 1 #define OpenIGTLink_PROTOCOL_VERSION_2 2