Fix windows build for gflags for time_tests (#3504)
GFlags builds multiple targets, require aligning build options on windows builds. FetchModule offloads project configuration to cmake. This also allows to align build configurations and targets across projects: https://crascit.com/2015/07/25/cmake-gtest/
This commit is contained in:
1 parent
d8f00acd39
commit
7fe21dc6ee
2 files changed
+21
-38
No files matched your search
@@ -4,14 +4,17 @@
|
||||
|
||||
cmake_minimum_required(VERSION 3.13 FATAL_ERROR)
|
||||
|
||||
if (CMAKE_BUILD_TYPE STREQUAL "")
|
||||
message(STATUS "CMAKE_BUILD_TYPE not defined, 'Release' will be used")
|
||||
set(CMAKE_BUILD_TYPE "Release")
|
||||
endif()
|
||||
set (CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the build type")
|
||||
|
||||
find_package(InferenceEngineDeveloperPackage QUIET)
|
||||
if (NOT InferenceEngineDeveloperPackage_FOUND)
|
||||
find_package(InferenceEngine REQUIRED)
|
||||
project(time_tests)
|
||||
|
||||
|
||||
find_package(InferenceEngine)
|
||||
if (NOT InferenceEngine_FOUND)
|
||||
set (HAVE_SYS_STAT_H 1)
|
||||
set (HAVE_INTTYPES_H 1)
|
||||
set (INTTYPES_FORMAT C99)
|
||||
find_package(InferenceEngineDeveloperPackage REQUIRED)
|
||||
endif()
|
||||
|
||||
add_subdirectory(src)
|
||||
@@ -8,36 +8,16 @@ file (GLOB SRC *.cpp)
|
||||
add_library(${TARGET_NAME} STATIC ${SRC})
|
||||
target_include_directories(${TARGET_NAME} PUBLIC "${CMAKE_SOURCE_DIR}/include")
|
||||
|
||||
find_package(gflags QUIET)
|
||||
if (gflags_FOUND)
|
||||
set(GFLAGS_LIBRARIES gflags) # use gflags from developer package
|
||||
else()
|
||||
include(ExternalProject)
|
||||
find_package(Threads)
|
||||
set(gflags_PREFIX ${CMAKE_BINARY_DIR}/external/gflags-prefix)
|
||||
set(gflags_INSTALL ${CMAKE_BINARY_DIR}/external/gflags-install)
|
||||
set(gflags_LIB ${gflags_INSTALL}/lib/libgflags.a)
|
||||
|
||||
ExternalProject_Add(
|
||||
gflags
|
||||
PREFIX ${gflags_PREFIX}
|
||||
GIT_REPOSITORY "https://github.com/gflags/gflags.git"
|
||||
GIT_TAG "v2.2.2"
|
||||
UPDATE_COMMAND ""
|
||||
INSTALL_DIR ${gflags_INSTALL}
|
||||
CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE}
|
||||
CMAKE_GENERATOR ${CMAKE_GENERATOR}
|
||||
CMAKE_GENERATOR_PLATFORM ${CMAKE_GENERATOR_PLATFORM}
|
||||
CMAKE_GENERATOR_TOOLSET ${CMAKE_GENERATOR_TOOLSET}
|
||||
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${gflags_INSTALL}
|
||||
EXCLUDE_FROM_ALL TRUE
|
||||
BUILD_BYPRODUCTS ${gflags_LIB}
|
||||
LOG_DOWNLOAD 1
|
||||
LOG_INSTALL 1
|
||||
)
|
||||
set(GFLAGS_LIBRARIES ${gflags_LIB} ${CMAKE_THREAD_LIBS_INIT})
|
||||
add_dependencies(${TARGET_NAME} gflags)
|
||||
target_include_directories(${TARGET_NAME} PRIVATE "${gflags_INSTALL}/include")
|
||||
include(FetchContent)
|
||||
FetchContent_Declare(
|
||||
gflags
|
||||
GIT_REPOSITORY "https://github.com/gflags/gflags.git"
|
||||
GIT_TAG "v2.2.2"
|
||||
)
|
||||
FetchContent_GetProperties(gflags)
|
||||
if(NOT gflags_POPULATED)
|
||||
FetchContent_Populate(gflags)
|
||||
add_subdirectory(${gflags_SOURCE_DIR} ${gflags_BINARY_DIR})
|
||||
endif()
|
||||
|
||||
target_link_libraries(${TARGET_NAME} ${GFLAGS_LIBRARIES})
|
||||
target_link_libraries(${TARGET_NAME} gflags)
|
||||
Reference in new issue
Block a user