Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable CMake ExternalProject_Add and other improvements #86

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

mratzloff
Copy link

Hi, here are three small changes related to CMake:

  1. Enable ExternalProject_Add calls from CMake in order to include tinyformat remotely. Because ExternalProject_Add requires an install step, I think this is as close to a no-op as possible for a header-only library.
  2. Make building tests optional (but default ON for backwards compatibility) to allow projects that are including the library to do so without building the tests.
  3. Add various generated CMake files to .gitignore.

Taken together, this allows a project to include tinyformat with something like the following code (this is set to my own branch that includes these commits):

set (tinyformat_prefix [...]/tinyformat_dep)

ExternalProject_Add (tinyformat_dep
	GIT_REPOSITORY https://github.com/mratzloff/tinyformat
	GIT_TAG 52f5a919de22c696b6fb55570b7210a9f3815b7e
	PREFIX ${tinyformat_prefix}
	CMAKE_CACHE_ARGS -DBUILD_TESTS:BOOL=OFF)

ExternalProject_Get_Property (tinyformat_dep SOURCE_DIR)
set (tinyformat_includes ${SOURCE_DIR})

target_include_directories (my_project PUBLIC ${tinyformat_includes})

I've tested this with my own project and it works great; previously it would fail during the test building phase, then the install phase (because it didn't exist).

[ 20%] Creating directories for 'tinyformat_dep'
[ 22%] Performing download step (git clone) for 'tinyformat_dep'
Cloning into 'tinyformat_dep'...
HEAD is now at 52f5a91 Enable inclusion into other CMake builds
[ 24%] Performing update step for 'tinyformat_dep'
[ 26%] No patch step for 'tinyformat_dep'
[ 28%] Performing configure step for 'tinyformat_dep'
loading initial cache file /path/to/_deps/tinyformat_dep/tmp/tinyformat_dep-cache-.cmake
-- The C compiler identification is AppleClang 13.1.6.13160021
-- The CXX compiler identification is AppleClang 13.1.6.13160021
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: /path/to/_deps/tinyformat_dep/src/tinyformat_dep-build
[ 31%] Performing build step for 'tinyformat_dep'
[ 33%] Performing install step for 'tinyformat_dep'
Install the project...
-- Install configuration: "Release"
-- Installing: /path/to/_deps/tinyformat_dep/src/tinyformat_dep/tinyformat.cmake
[ 35%] Completed 'tinyformat_dep'
[ 35%] Built target tinyformat_dep

Let me know if you have any questions!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant