Reputation: 2920
I have an external project that generates a compiler
include(ExternalProject)
ExternalProject_Add(gprolog
GIT_REPOSITORY "[email protected]:didoudiaz/gprolog.git"
GIT_TAG "master"
SOURCE_DIR "${CMAKE_SOURCE_DIR}/3rdparty/gprolog"
BUILD_IN_SOURCE true
CONFIGURE_COMMAND cd src && ./configure --with-install-dir=${CMAKE_SOURCE_DIR}/3rdparty/gprolog-build
BUILD_COMMAND cd src && make
INSTALL_COMMAND cd src && make install
)
Consequently, I'd like to run:
add_executable(runner src/runner.c app/application.pro)
include_directories(runner "${CMAKE_SOURCE_DIR}/3rdparty/gprolog-build/include")
but instead of gcc
or clang
, I need to use ${CMAKE_SOURCE_DIR}/3rdparty/gprolog-build/bin/gplc
.
When I politely ask CMake to pretend that gplc
is just another C compiler by adding
set(CMAKE_C_COMPILER "${CMAKE_SOURCE_DIR}/3rdparty/gprolog-build/bin/gplc")
it screams at me with
Cannot get compiler information:
Compiler exited with error code 1: .../gprolog/3rdparty/gprolog-build/bin/gplc -xc -g -isysroot ..../Developer/SDKs/MacOSX11.3.sdk -fpch-preprocess -v -dD -E
Apple clang version 12.0.5 (clang-1205.0.22.11)
Target: x86_64-apple-darwin20.5.0
Thread model: posix
InstalledDir: .../XcodeDefault.xctoolchain/usr/bin
clang: warning: -lm: 'linker' input unused [-Wunused-command-line-argument]
clang: error: cannot specify -o when generating multiple output files
compilation failed
Upvotes: 1
Views: 169
Reputation: 20026
Short of reverse engineering CMake's enable_language
implementation modules to add your own for Prolog, you can always go the route of add_custom_command
and ask your compiler to generate object files, which can be included as sources in the add_executable
command.
If you add some detail to the question about how the Prolog compiler works, I can help you write the custom commands.
Upvotes: 1