1

I am working on a project that uses libraries included as subdirectories, however, one of them doesn't use CMake.

Here's the directory structure:

- src
-- tinyxml2
-- ziplib
-- [sources-here]

How would I include ziplib as it doesn't use CMake as its build tool?

Bast
  • 72
  • 9

1 Answers1

1

CMake supports execution of arbitrary commands via add_custom_command. So whatever buildsystem ziplib is using, there will be a way to trigger it via a terminal command.

If you are referring to ziplib from https://bitbucket.org/wbenny/ziplib and you happen to build it for Windows, then you can add something similar to the following to you CMakeLists.txt file:

add_custom_command(
  OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/build.log
  COMMAND msbuild /m /t:Build /p:Platform=x64 /p:Configuration=Release ZipLib.sln
)

There is a good description of add_custom_command in How to Run a Basic `add_custom_command` in CMake.

salchint
  • 371
  • 3
  • 10
  • How would I then link it as a library? – Bast Dec 15 '18 at 21:20
  • `target_link_libraries` is the command you are looking for. https://stackoverflow.com/questions/14468678/cmake-link-a-library-to-library/14469240#14469240 describes its usage. – salchint Dec 17 '18 at 23:06