Skip to content

Instantly share code, notes, and snippets.

@samee
Created November 29, 2019 21:17
Show Gist options
  • Save samee/a5f8f1f5f133192dc8ef3f933f3f35da to your computer and use it in GitHub Desktop.
Save samee/a5f8f1f5f133192dc8ef3f933f3f35da to your computer and use it in GitHub Desktop.
Using ExternalProject with cmake
cmake_minimum_required(VERSION 3.10)
include(ExternalProject)
ExternalProject_Add(fmtlib
GIT_REPOSITORY https://github.com/fmtlib/fmt.git
EXCLUDE_FROM_ALL TRUE
BUILD_COMMAND $(MAKE) fmt
STEP_TARGETS build)
set(fmtlib_BINARY_DIR "${CMAKE_BINARY_DIR}/fmtlib-prefix/src/fmtlib-build")
set(fmtlib_SOURCE_DIR "${CMAKE_BINARY_DIR}/fmtlib-prefix/src/fmtlib/include")
add_executable(fmttest fmttest.cpp)
add_dependencies(fmttest fmtlib-build)
target_link_libraries(fmttest ${fmtlib_BINARY_DIR}/libfmt.a)
target_include_directories(fmttest PUBLIC ${fmtlib_SOURCE_DIR})
# Tested with fmttest.cpp:
#
# #include "fmt/format.h"
# int main() { fmt::print("Hello {}!\n", "world"); }
#
# The trouble is, there is no easy way to make network-update optional.
# It kicks and screams if there is no network connection. There has to be a way
# To make updates optional.
@fricpa
Copy link

fricpa commented Jan 17, 2024

maybe have a look at how this is done: http://google.github.io/googletest/quickstart-cmake.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment