Skip to content

Commit

Permalink
Fix glog & gflags cmake interaction
Browse files Browse the repository at this point in the history
  • Loading branch information
maksbotan authored and ofrei committed Dec 6, 2017
1 parent b5c620c commit 678dec5
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions 3rdparty/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,29 @@ else (MSVC)
add_definitions("-w")
endif (MSVC)

# This line enables install(EXPORT) in gflags
# If it's missing, glog complains about it later in the build process
# Nothing is actually installed due to ECLUDE_FROM_ALL
set(INSTALL_STATIC_LIBS "ON")
set(BUILD_TESTING "OFF" CACHE "" INTERNAL)

add_subdirectory(gflags EXCLUDE_FROM_ALL)

# We use target included directly from gflags, so we need to disable find_package for it
# And trick glog's CMakeLists into believing we have gflags
set(CMAKE_DISABLE_FIND_PACKAGE_gflags "ON")
# Do not call find_package for gflags and fill all relevant info manually
# We cannot make glog link to gflags __target__, because cmake would try to
# pull it into glog's export set and will get confused and fail
# Instead we manually specify location and include path for gflags, this way
# cmake does not create inter-target dependency and export set does not fail
set(WITH_GFLAGS "OFF" CACHE "" INTERNAL)
set(HAVE_LIB_GFLAGS "ON")
set(gflags_NAMESPACE "gflags")
set(gflags_FOUND "ON")
# This one tricks cmake into adding correct include dirs, dependent libraries, etc on target_link_libraries call in glog
set(gflags_LIBRARIES gflags)
get_target_property(gflags_INCLUDE_DIR gflags INTERFACE_INCLUDE_DIRECTORIES)
get_target_property(gflags_LIBRARIES gflags INTERFACE_LINK_LIBRARIES)
set(gflags_LIBRARIES $<TARGET_FILE:gflags> ${gflags_LIBRARIES})

add_subdirectory(glog EXCLUDE_FROM_ALL)

# We need to ask CMake to compile gflags before compiling glog, so that
# ${gflags_LIBRARIES} actually exists
add_dependencies(glog gflags)

set(CMAKE_INSTALL_INCLUDEDIR include/artm)
add_subdirectory(protobuf-3.0.0/cmake EXCLUDE_FROM_ALL)
set(PROTOBUF_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/protobuf-3.0.0/cmake CACHE "" INTERNAL)

0 comments on commit 678dec5

Please sign in to comment.