-
-
Save tcavallari/5aecd60f5daab53e5b38 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
########################### GTEST | |
# Enable ExternalProject CMake module | |
INCLUDE(ExternalProject) | |
# Set default ExternalProject root directory | |
SET_DIRECTORY_PROPERTIES(PROPERTIES EP_PREFIX ${CMAKE_BINARY_DIR}/3rdparty) | |
# Add gtest | |
# http://stackoverflow.com/questions/9689183/cmake-googletest | |
ExternalProject_Add( | |
googletest | |
URL https://googletest.googlecode.com/files/gtest-1.7.0.zip | |
# TIMEOUT 10 | |
# # Force separate output paths for debug and release builds to allow easy | |
# # identification of correct lib in subsequent TARGET_LINK_LIBRARIES commands | |
CMAKE_ARGS -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG:PATH=Debug | |
-DCMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE:PATH=Release | |
-Dgtest_force_shared_crt=ON | |
# Disable install step | |
INSTALL_COMMAND "" | |
# Wrap download, configure and build steps in a script to log output | |
LOG_DOWNLOAD ON | |
LOG_CONFIGURE ON | |
LOG_BUILD ON) | |
# Specify include dir | |
ExternalProject_Get_Property(googletest source_dir) | |
set(GTEST_INCLUDE_DIR ${source_dir}/include) | |
# Library | |
ExternalProject_Get_Property(googletest binary_dir) | |
set(GTEST_LIBRARIES gtest) | |
add_library(${GTEST_LIBRARIES} UNKNOWN IMPORTED) | |
set_property(TARGET ${GTEST_LIBRARIES} PROPERTY | |
IMPORTED_LOCATION_DEBUG "${binary_dir}/Debug/${CMAKE_FIND_LIBRARY_PREFIXES}${GTEST_LIBRARIES}${CMAKE_FIND_LIBRARY_SUFFIXES}") | |
set_property(TARGET ${GTEST_LIBRARIES} PROPERTY | |
IMPORTED_LOCATION_RELEASE "${binary_dir}/Release/${CMAKE_FIND_LIBRARY_PREFIXES}${GTEST_LIBRARIES}${CMAKE_FIND_LIBRARY_SUFFIXES}") | |
add_dependencies(${GTEST_LIBRARIES} googletest) | |
set(GTEST_MAIN_LIBRARIES gtest_main) | |
add_library(${GTEST_MAIN_LIBRARIES} UNKNOWN IMPORTED) | |
set_property(TARGET ${GTEST_MAIN_LIBRARIES} PROPERTY | |
IMPORTED_LOCATION_DEBUG "${binary_dir}/Debug/${CMAKE_FIND_LIBRARY_PREFIXES}${GTEST_MAIN_LIBRARIES}${CMAKE_FIND_LIBRARY_SUFFIXES}") | |
set_property(TARGET ${GTEST_MAIN_LIBRARIES} PROPERTY | |
IMPORTED_LOCATION_RELEASE "${binary_dir}/Release/${CMAKE_FIND_LIBRARY_PREFIXES}${GTEST_MAIN_LIBRARIES}${CMAKE_FIND_LIBRARY_SUFFIXES}") | |
add_dependencies(${GTEST_MAIN_LIBRARIES} googletest) | |
set(GTEST_BOTH_LIBRARIES ${GTEST_LIBRARIES} ${GTEST_MAIN_LIBRARIES}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Tried this because it looked really clean but am getting:
From the gtest build using cmake 3.3.2. Any ideas?