I am trying to add Postgresql as a dependency for my project for which I am using ExternalProject module to download the source from github and build, but the build step fails when running from cmake (cmake --build .). Configure step seems to succeed and if I go to the Build directory under EP_BASE and do a make it runs successfully. I get the following error during build:
<...>/Source/postgresql_external/src/common/relpath.c:21:10: fatal error: catalog/pg_tablespace_d.h: No such file or directory
21 | #include "catalog/pg_tablespace_d.h"
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
make[5]: *** [<builtin>: relpath.o] Error 1
make[4]: *** [Makefile:42: all-common-recurse] Error 2
make[3]: *** [GNUmakefile:11: all-src-recurse] Error 2
My external project add looks like the following:
ExternalProject_Add(postgresql_external
GIT_REPOSITORY https://github.com/postgres/postgres.git
GIT_TAG REL_12_4
CONFIGURE_COMMAND <SOURCE_DIR>/configure --prefix=<INSTALL_DIR>
LOG_CONFIGURE 1
LOG_BUILD 1
LOG_INSTALL 1
)
This is running on Ubuntu 20.04 LTS, with cmake 3.16.3, gcc 9.3.0
try
ExternalProject_Get_Property(postgresql_external install_dir)
include_directories(${install_dir}/include)
I guess, you haven't propagate include directory to your target yet, but it is evtl. known to your system (thus successful call of manually called make)
Try the following code, it works for me. PotgreSQL uses MAKELEVEL variable to generate header files via perl. When you call make directly it works as expected. But it seems that cmake adds more levels to PotgreSQL's root make, so headers are not generated.
CONFIGURE_COMMAND ./configure <your options>
BUILD_IN_SOURCE 1
BUILD_COMMAND $(MAKE) MAKELEVEL=0
Related
I am getting the following error :
CMake Error at CMakeLists.txt:9 (BISON_TARGET):
Unknown CMake command "BISON_TARGET".
when I run the command :
cmake .. -GNinja
Please tell me what to do. I tried searching on google a lot and thus came up with the additions and finally ran the command :
cmake .. -D LLVM_DIR=/usr/lib/llvm-5.0/cmake/ -D FLEX_EXECUTABLE=/usr/local/Cellar/flex/2.5.37/bin/ -D FLEX_INCLUDE_DIR=/usr/local/Cellar/flex/2.5.37/include/ -D BISON_EXECUTABLE=/usr/bin/bison
but it still shows the same error :(.
Please someone help.
Your error is occurring because the BISON_TARGET function definition has not yet been supplied. This method, as commented, is supplied by FindBISON. The error indicates that either Bison was not found on your system (hopefully, you have it installed), or cmake was ran from the wrong directory. Bison is included in the top-level CMake file via:
find_package(BISON REQUIRED)
This line to include Bison must be called before using the BISON_TARGET CMake function. The LLReve instructions for compiling this repository are explicit about which directory to run the build commands in:
Go to the llreve directory and run
cd reve
mkdir build
cd build
cmake .. -GNinja
ninja
This would run on the CMake file in the llreve/reve directory, not the llreve/reve/reve directory. Please ensure you are running CMake from the correct location, as not running cmake on the top-level CMake file will often yield errors.
im very new to cmake.
I want to add eclipse paho to my project, therefor I use "ExternalProject_add". Here is an extract of my CMakeLists.txt:
ExternalProject_add(
libressl
URL ${CMAKE_SOURCE_DIR}/externals/libressl-2.5.0.tar.gz
CONFIGURE_COMMAND ./configure --disable-hardening --prefix=${CMAKE_BINARY_DIR}
BUILD_IN_SOURCE 1)
ExternalProject_add(
paho
DEPENDS libressl
URL ${CMAKE_SOURCE_DIR}/externals/eclipse-paho-mqtt-c-src-1.1.0.tar.gz
CMAKE_ARGS -DPAHO_WITH_SSL -DOPENSSL_INC_SEARCH_PATH=${CMAKE_SOURCE_DIR}/include -DOPENSSL_LIB_SEARCH_PATH=${CMAKE_SOURCE_DIR}/lib
BUILD_COMMAND make
BUILD_IN_SOURCE 1)
The thing is libressl is building just fine. As you can see it uses autoconf-tools.
My Problem is that paho throws an error at the "configure step".
~/projects/cmake_test/CL_Test/build$ cmake ..
-- Configuring done
-- Generating done
-- Build files have been written to: /projects/cmake_test/CL_Test/build
:~/projects/cmake_test/CL_Test/build$ make
[ 50%] Built target libressl
[ 56%] Performing configure step for 'paho'
CMake Error at /projects/cmake_test/CL_Test/build/paho-prefix/src/paho-stamp/paho-configure-.cmake:16 (message):
Command failed: 1
'/usr/bin/cmake' '-DPAHO_WITH_SSL' '-DOPENSSL_INC_SEARCH_PATH=/home/hbaumann/projects/cmake_test/CL_Test/include' '-DOPENSSL_LIB_SEARCH_PATH=/home/hbaumann/projects/cmake_test/CL_Test/lib' '-GUnix Makefiles' '/projects/cmake_test/CL_Test/build/paho-prefix/src/paho'
CMakeFiles/paho.dir/build.make:107: recipe for target 'paho-prefix/src/paho-stamp/paho-configure' failed
make[2]: *** [paho-prefix/src/paho-stamp/paho-configure] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/paho.dir/all' failed
make[1]: *** [CMakeFiles/paho.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2
I thought, since paho is build with the use of CMake by default, there is nothing I really need to add. Here you can see, my knowledge about CMake is really low.
What makes me wonder is that in the paho tar-ball, there is only a Makefile in the main folder and not an CMakeLists.txt.
What do i miss... is there a special configure command I need to set ?
thx in advance
you can use the GIT repository, it has a CMakeList.txt.
ExternalProject_add(
paho
DEPENDS libressl
GIT_REPOSITORY "https://github.com/eclipse/paho.mqtt.c.git"
GIT_TAG "master"
UPDATE_COMMAND ""
PATCH_COMMAND ""
SOURCE_DIR "${CMAKE_BINARY_DIR}/paho_sourcedir"
CMAKE_ARGS -DPAHO_WITH_SSL=TRUE -DOPENSSL_INC_SEARCH_PATH=${CMAKE_BINARY_DIR}/include -DOPENSSL_LIB_SEARCH_PATH=${CMAKE_BINARY_DIR}/lib -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/paho_prefix
)
I'm building dependency project with cmake ExternalProject_Add command:
include(ExternalProject)
...
set(COMMON_BASE_PROJECT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../CommonBase)
ExternalProject_Add(CommonBaseProject
SOURCE_DIR ${COMMON_BASE_PROJECT_DIR}
BINARY_DIR ${COMMON_BASE_PROJECT_DIR}/build
INSTALL_COMMMAND ""
)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
include_directories(${COMMON_BASE_PROJECT_DIR}/include)
add_library(
${LIBRARY_NAME}
SHARED
${SRC_FILES}
${INCLUDE_FILES}
)
target_link_libraries (Bios ${COMMON_BASE_PROJECT_DIR}/build/libCommonBase.dll)
add_dependencies(Bios CommonBaseProject)
but i get error:
[100%] Linking CXX shared library libCommonBase.dll
[100%] Built target CommonBase
[ 50%] Performing install step for 'CommonBaseProject'
make[3]: *** No rule to make target 'install'. Stop.
I don't need to make install step, so my question is: how to disable it?
You almost had it: Instead of INSTALL_COMMAND "" put something like
INSTALL_COMMAND cmake -E echo "Skipping install step."
You can generate a target for the build step with STEP_TARGETS build and add dependency on this particular target. The step targets are named <external-project-name>-<step-name> so in this case the target representing the build step will be named CommonBaseProject-build.
You probably also want to exclude the CommonBaseProject from the "all" target with EXCLUDE_FROM_ALL TRUE.
ExternalProject_Add(CommonBaseProject
SOURCE_DIR ${COMMON_BASE_PROJECT_DIR}
BINARY_DIR ${COMMON_BASE_PROJECT_DIR}/build
STEP_TARGETS build
EXCLUDE_FROM_ALL TRUE
)
add_dependencies(Bios CommonBaseProject-build)
Not relevant to your question, which it was already answered, but in my case I had the following ExternalProject_Add directive:
ExternalProject_Add(external_project
# [...]
# Override build/install command
BUILD_COMMAND ""
INSTALL_COMMAND
"${CMAKE_COMMAND}"
--build .
--target INSTALL # Wrong casing for "install" target
--config ${CMAKE_BUILD_TYPE}
)
In this case cmake quits with very similar error (*** No rule to make target 'INSTALL'), but in this case it's the external project that is looking for incorrect uppercase INSTALL target: correct case is install instead. Apparently, that worked in Windows with MSVC but fails in unix operating systems.
Since at least CMake 3.10 the empty string is sufficient to suppress the install step:
Passing an empty string as the <cmd> makes the install step do nothing.
The same goes for the other stages; see the docs for more.
If you're still building with CMake <3.10 then you need to update CMake ;)
For a new project we want to use CMake. We are using Eclipse CDT as IDE and Cygwin gcc.
We generated the CMakeLists.txt and followed [this tutorial (option 2)][1].
When I try to run the described Make target to generate the Makefiles with CMake, which executes
cmake -E chdir C:/projects/eclipse_ws/MyApp/Build/ cmake -G "Unix Makefiles" ../ Run CMake
I get the error
CMake Error: The source directory "C:/projects/eclipse_ws/MyApp/Build/CMake" does not exist.
If I run the command directly from a Cygwin console it works just fine, however then I have to run make also from the Cygwin console, because the Makefiles are generated with Unix paths.
EDIT:
So I fixed this issue (see my answer below).
But I'm still having problems.
When I try to run CMake as Make target in Eclipse as suggested in the tutorial I get the following errors:
cmake -E chdir Build/ cmake -G 'Unix Makefiles' ../
-- The C compiler identification is unknown
-- The CXX compiler identification is unknown
System is unknown to cmake, create:
Platform/MINGW32_NT-6.1 to use this system, please send your config file to cmake#www.cmake.org so it can be added to cmake
Your CMakeCache.txt file was copied to CopyOfCMakeCache.txt. Please send that file to cmake#www.cmake.org.
-- Check for working C compiler: /usr/bin/gcc.exe
System is unknown to cmake, create:
Platform/MINGW32_NT-6.1 to use this system, please send your config file to cmake#www.cmake.org so it can be added to cmake
-- Check for working C compiler: /usr/bin/gcc.exe -- broken
CMake Error at /usr/share/cmake-2.8.9/Modules/CMakeTestCCompiler.cmake:52 (MESSAGE):
The C compiler "/usr/bin/gcc.exe" is not able to compile a simple test
program.
It fails with the following output:
Change Dir: /cygdrive/c/projects/eclipse_ws/MyApp/Build/CMakeFiles CMakeTmp
Run Build Command:/usr/bin/make.exe "cmTryCompileExec726566634/fast"
/usr/bin/make -f CMakeFiles/cmTryCompileExec726566634.dir/build.make
CMakeFiles/cmTryCompileExec726566634.dir/build
make[1]: Entering directory
'/cygdrive/c/projects/eclipse_ws/MyApp/Build/CMakeFiles/CMakeTmp'
/usr/bin/cmake.exe -E cmake_progress_report
/cygdrive/c/projects/eclipse_ws/MyApp/Build/CMakeFiles/CMakeTmp/CMakeFiles
1
Building C object
CMakeFiles/cmTryCompileExec726566634.dir/testCCompiler.c.obj
/usr/bin/gcc.exe -o
CMakeFiles/cmTryCompileExec726566634.dir/testCCompiler.c.obj -c
/cygdrive/c/projects/eclipse_ws/MyApp/Build/CMakeFiles/CMakeTmp/testCCompiler.c
CMakeFiles/cmTryCompileExec726566634.dir/build.make:60: recipe for target
'CMakeFiles/cmTryCompileExec726566634.dir/testCCompiler.c.obj' failed
make[1]: Leaving directory
'/cygdrive/c/projects/eclipse_ws/MyApp/Build/CMakeFiles/CMakeTmp'
make[1]: *** [CMakeFiles/cmTryCompileExec726566634.dir/testCCompiler.c.obj]
Error 1
Makefile:117: recipe for target 'cmTryCompileExec726566634/fast' failed
make: *** [cmTryCompileExec726566634/fast] Error 2
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:3 (project)
-- Configuring incomplete, errors occurred!
Seems like for some reason CMake assumes I have an MinGW environment and not Cygwin.
EDIT2
MinGW system was assumed, because a Git installation was in PATH before Cygwin and Git's uname command was used (which returns MinGW).
If you check "Make Target - Same as the target name" in Eclipse's Make dialog, Eclipse will add a
Run CMake
to the command (see question), which is misinterpreted by CMake.
I just unchecked "Same as the target name".
I would like to install QGLViewer as an external from source code in a cmake build environment. This is what I have tried so far:
set(QGLViewer_VERSION 2.5.2)
set(QGLViewer_URL_REMOTE "http://www.libqglviewer.com/src/libQGLViewer-${QGLViewer_VERSION}.tar.gz")
ExternalProject_Add(QGLViewer
PREFIX ${CMAKE_CURRENT_BINARY_DIR}/external/qglviewer
URL ${QGLViewer_URL_REMOTE}
BUILD_IN_SOURCE 1
CONFIGURE_COMMAND qmake PREFIX="${CMAKE_CURRENT_BINARY_DIR}/external/qglviewer" QGLVIEWER_STATIC=yes
BUILD_COMMAND make
)
cmake works just fine.
However, when running make, I get a bunch of compilation errors. make is finding the headers installed in my system instead of the ones of the build project directory:
make[4]: warning: jobserver unavailable: using -j1. Add `+' to parent make rule.
Project MESSAGE: Warning: unknown QT: widgets
In file included from /usr/include/QGLViewer/manipulatedFrame.h:26:0,
from /usr/include/QGLViewer/manipulatedCameraFrame.h:26,
from /usr/include/QGLViewer/camera.h:26,
from /usr/include/QGLViewer/qglviewer.h:26,
from animation.h:23,
from animation.cpp:23:
/usr/include/QGLViewer/frame.h:139:3: error: ‘signals’ does not name a type
/usr/include/QGLViewer/frame.h:404:10: error: expected ‘:’ before ‘slots’
/usr/include/QGLViewer/frame.h:404:10: error: ‘slots’ does not name a type
NaN
The solution is to specify to perform the qmake on the file QGLViewer/QGLViewer.pro instead of the default .pro file located in the root folder libQGLViewer-2.5.2/
ExternalProject_Add(QGLViewer
PREFIX ${CMAKE_CURRENT_BINARY_DIR}/external/qglviewer
URL ${QGLViewer_URL_REMOTE}
DOWNLOAD_DIR ${QGLViewer_DSTDIR}
BUILD_IN_SOURCE 1
CONFIGURE_COMMAND qmake QGLViewer/QGLViewer.pro QGLVIEWER_STATIC=yes PREFIX=${CMAKE_CURRENT_BINARY_DIR}/external/qglviewer
BUILD_COMMAND make
)