1

I'm trying to create a CMake project that integrates 2 sub-projects, specifically botan and rnpgp. The build system of rnpgp is CMake-based, botan uses a Python configure script to generate a Makefile. The problem is that during the CMake run rnpgp checks for features in botan, so it requires a compiled botan library. But, botan doesn't get built until I actually call make, which I can't do because rnpgp fails to configure because botan isn't built yet.

What's the right way to specify such a dependency in CMake?

Kevin
  • 16,549
  • 8
  • 60
  • 74
jpo234
  • 419
  • 3
  • 9
  • do you have some code that you can share and tell us where the problem is? – Ibo Dec 18 '19 at 18:53
  • What I basically want to do is a cmake based build of rnpgp on a system where botan is not installed. That's it. – jpo234 Dec 19 '19 at 08:33

1 Answers1

1

You could use CMake's execute_process() to run the botan Python script and run make during the CMake configure stage. This way, the botan library will be built and available to reference when running the mpgp CMake:

# Run the Python script to configure the botan Makefile.
execute_process(COMMAND
    python ${CMAKE_SOURCE_DIR}/botan/configure.py
    WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
)
# Run 'make' from the botan directory where the 'Makefile' was created.
execute_process(COMMAND
    make
    WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/botan/build"
)

This is a rough example of what it could look like. You may have to modify the paths a bit to match where you have botan on your system, and where botan generates its build artifacts (i.e. location of the Makefile).

Kevin
  • 16,549
  • 8
  • 60
  • 74