Is it possible to have a timer during a CMake build? - cmake

I need to measure the time spent by different steps during a CMake build.
Currently my build logs look like this :
Scanning dependencies of target TARGET1
[ 75%] Building TARGET1
[ 75%] Generating TARGET1 description file
[ 75%] Built target TARGET1
Scanning dependencies of target TARGET2
[ 75%] Building TARGET2
[ 75%] Generating TARGET2 description file
[ 75%] Built target TARGET2
Scanning dependencies of target TARGET3
[ 75%] Building TARGET3
[ 75%] Generating TARGET3 description file
[ 75%] Built target TARGET3
Scanning dependencies of target TARGET4
[ 75%] Building TARGET4
[ 75%] Generating TARGET4 description file
[ 75%] Built target TARGET4
What I would like to do is having something like that :
[build] [770/1170 64% :: 44.419] Building TARGET1
[build] [771/1170 64% :: 44.431] Building TARGET2
[build] [772/1170 64% :: 44.745] Building TARGET3
[build] [773/1170 64% :: 44.873] Generating TARGET1
[build] [774/1170 64% :: 44.934] Building TARGET4
Here we see a timer on the right which is very helpful to see which steps takes more time etc... The last logs come from the CMake plugin of VScode but I don't know how to display the same timer with a classical use of CMake.
Anyone knows how to do this ? Is there just an option to activate of something like that ?
Thx !

Related

Linker fails building library with CMake

I'm trying to build LUAGLM (from https://github.com/gottfriedleibniz/lua) to bind GLM library to give access in Lua using cmake. When i build, the building completes ok but the linker does not giving error:
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [glm.so] Error 1
make[1]: *** [CMakeFiles/glm.dir/all] Error 2
make: *** [all] Error 2
Above these lines there is a very long list starting with:
[ 10%] Building CXX object CMakeFiles/liblua.dir/onelua.c.o
[ 20%] Linking CXX shared library liblua54.dylib
[ 20%] Built target liblua
[ 30%] Building CXX object CMakeFiles/liblua_static.dir/onelua.c.o
[ 40%] Linking CXX static library liblua54_static.a
[ 40%] Built target liblua_static
[ 50%] Building C object CMakeFiles/lua.dir/lua.c.o
[ 60%] Linking CXX executable lua
[ 60%] Built target lua
[ 70%] Building CXX object CMakeFiles/luac.dir/onelua.c.o
[ 80%] Linking CXX executable luac
[ 80%] Built target luac
[ 90%] Building CXX object CMakeFiles/glm.dir/libs/glm_binding/lglmlib.cpp.o
[100%] Linking CXX shared module glm.so
Undefined symbols for architecture x86_64:
"glm_pushmat(lua_State*, glmMatrix const&)", referenced from:
glm_mat_add(lua_State*) in lglmlib.cpp.o
glm_mat_sub(lua_State*) in lglmlib.cpp.o
glm_mat_mul(lua_State*) in lglmlib.cpp.o
glm_mat_negate(lua_State*) in lglmlib.cpp.o
glm_mix(lua_State*) in lglmlib.cpp.o
glm_saturation(lua_State*) in lglmlib.cpp.o
glm_orthonormalize(lua_State*) in lglmlib.cpp.o
...
I'm on MacOS Intel (i386-apple-darwin11.3.0)
Not sure where to go next, do I need to edit the CMakeList somehow?
Any help much appreciated
EDIT:
The cmake error log contains the following :
Compiling the C compiler identification source file "CMakeCCompilerId.c" failed. Compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc Build flags: Id flags:
The output was: 1 ld: library not found for -lSystem clang: error: linker command failed with exit code 1 (use -v to see invocation)
Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" failed. Compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ Build flags: Id flags:
The output was: 1 ld: library not found for -lc++ clang: error: linker command failed with exit code 1 (use -v to see invocation)
This is actually a bug in the CMakeList.txt because the library-list for the glm.so module does not contain the liblua.
If you apply the following patch
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 8cf8a1a6..6eda2a17 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
## -940,7 +940,7 ## ENDIF()
ADD_LIBRARY(glm MODULE ${SRC_LIBGLM})
TARGET_INCLUDE_DIRECTORIES(glm PRIVATE ${INCLUDE_DIRECTORIES})
-TARGET_LINK_LIBRARIES(glm PRIVATE ${LIBS})
+TARGET_LINK_LIBRARIES(glm PRIVATE ${LIBS} liblua_static)
IF( LUA_BUILD_AS_DLL )
TARGET_LINK_LIBRARIES(glm PUBLIC ${interpretor_target})
TARGET_COMPILE_DEFINITIONS(glm PRIVATE LUA_BUILD_AS_DLL)
to the freshly cloned repository and then do (inside the cloned repository):
git submodule update --init
mkdir build
cd build
cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DONE_LUA=ON ..
make
you should find the files glm.so, lua and luac in your build directory. At least that worked on my Intel MacBook.
Using liblua_static in the CMakeList.txt for the library glm makes sure, that the resulting glm.so does not need the liblua dynamic library but contains the required code statically. That avoids problems when loading glm.so and the liblua library not being in the library path.
I opened an issue in the GitHub repository for it. So hopefully it will get fixed for everybody soon.
Usually it'll be something like -lYourLibrary not found, if -lSystem for example is not found, try adding it to your CMakeLists.
Are you still having the issue?

make: have built target; make install : *** No rule to make target 'install'

In Ubuntu20.04.
I want to insatll easy3d, but I can not make install it successfully.
make
[ 83%] Building CXX object CMakeFiles/easy3d.dir/surface_mesh_io_obj.cpp.o
[ 87%] Building CXX object CMakeFiles/easy3d.dir/surface_mesh_io_off.cpp.o
[ 91%] Building CXX object CMakeFiles/easy3d.dir/surface_mesh_io_ply.cpp.o
[ 95%] Building CXX object CMakeFiles/easy3d.dir/transform.cpp.o
[100%] Linking CXX static library libeasy3d.a
[100%] Built target easy3d
And the build have files:
CMakeCache.txt CMakeFiles Makefile cmake_install.cmake libeasy3d.a
Then I excute the command make install, I got
make: *** No rule to make target 'install'. Stop.
How could I fix it
I made a big mistake that is nothing to install.

Doxygen docs installation fails due to EPSTOPDF-NOTFOUND error

I'm trying to build the Doxygen documentation. I can get the html files to build and load properly in the borwser. However, the PDF files do not build properly.
When I execute make docs (as stated in the Doxygen installation instructions), the following is the error output:
[ 37%] Built target _doxygen
[ 38%] Built target md5
[ 38%] Built target lodepng
[ 45%] Built target mscgen
[ 45%] Checking the git repository for changes...
[ 45%] Built target check_git_repository
[ 46%] Checking the doxygen version for changes...
[ 46%] Built target check_doxygen_version
[ 47%] Built target doxygen_version
[ 55%] Built target qtools
[ 55%] Built target generate_configvalues_header
[ 57%] Built target vhdlparser
[ 61%] Built target doxycfg
[ 61%] Built target doxygen
[ 85%] Built target examples
[ 85%] Generating Latex and HTML documentation.
[100%] Built target run_doxygen
[100%] Generating Doxygen Manual PDF.
/bin/sh: 1: EPSTOPDF-NOTFOUND: not found
doc/CMakeFiles/doxygen_pdf.dir/build.make:57: recipe for target 'doc/CMakeFiles/doxygen_pdf' failed
make[3]: *** [doc/CMakeFiles/doxygen_pdf] Error 127
CMakeFiles/Makefile2:637: recipe for target 'doc/CMakeFiles/doxygen_pdf.dir/all' failed
make[2]: *** [doc/CMakeFiles/doxygen_pdf.dir/all] Error 2
CMakeFiles/Makefile2:671: recipe for target 'doc/CMakeFiles/docs.dir/rule' failed
make[1]: *** [doc/CMakeFiles/docs.dir/rule] Error 2
Makefile:379: recipe for target 'docs' failed
make: *** [docs] Error 2
I have searched online extensively and installed all font packages I can find regarding the TexLive package, and I have installed the pdflatex package as well.
Help is appreciated, thank you!

CMAKE - Add library don't work last turn of foreach

I have a CMakelist.txt :
cmake_minimum_required(VERSION 3.12)
project(test)
set(TEST_HOME ${CMAKE_CURRENT_SOURCE_DIR})
message("test SDK home directory: " ${TEST_HOME})
set(a true)
list(APPEND plugins a)
set(b true)
list(APPEND plugins b)
set(c true)
list(APPEND plugins c)
add_executable(test main.c)
foreach(plugin IN LISTS plugins)
if(${${plugin}})
file(GLOB ${plugin}-SRC "${TEST_HOME}/plugins/${plugin}/src/*.c")
message(${${plugin}-SRC})
add_library(slt_${plugin} SHARED ${${plugin}-SRC})
message(${plugin})
target_link_libraries(test slt_${plugin}.so)
endif()
endforeach()
TLDR: I turn for create libraries and link them to my executable.
But my last library isn't created, the output of my Makefile generate by this CMakelist.txt is :
Scanning dependencies of target slt_c
[ 12%] Building C object CMakeFiles/slt_c.dir/plugins/c/src/c.c.o
[ 25%] Linking C shared library libslt_c.so
[ 25%] Built target slt_c
Scanning dependencies of target slt_b
[ 37%] Building C object CMakeFiles/slt_b.dir/plugins/b/src/b.c.o
[ 50%] Linking C shared library libslt_b.so
[ 50%] Built target slt_b
[ 62%] Linking C executable minko
/usr/bin/x86_64-linux-gnu-ld: cannot find -lslt_a
/usr/bin/x86_64-linux-gnu-ld: cannot find -lslt_b
/usr/bin/x86_64-linux-gnu-ld: cannot find -lslt_c
And when I turn a to false. It's be who don't build.
I really don't know what cause this, I just start CMAKE with some tests. Thank you.

Cmake building error for Vortex86DX Linux 2.6.23 platform

I´m trying to build CMAKE to an embedded platform based on Vortex86DX processor - Linux 2.6.23 kernel.
I´ve downloaded the latest CMAKE package (3.4.1), add did:
./bootstrap
Then: make
Here is the make result with the error message:
$ make
[ 1%] Built target cmIML_test
[ 4%] Built target cmsys
[ 5%] Built target cmsysTestDynload
[ 6%] Built target cmsys_c
[ 6%] Built target cmsysTestProcess
[ 6%] Built target cmsysTestSharedForward
[ 7%] Built target cmsysTestsC
[ 9%] Built target cmsysTestsCxx
[ 11%] Built target cmzlib
[ 28%] Built target cmcurl
[ 28%] Built target LIBCURL
[ 29%] Built target cmcompress
[ 30%] Built target cmbzip2
[ 40%] Built target cmliblzma
[ 41%] Building C object Utilities/cmlibarchive/libarchive/CMakeFiles/cmlibarchive.dir/archive_write_disk_posix.c.o
/home/ftp/pub/cmake-3.4.1/cmake-3.4.1/Utilities/cmlibarchive/libarchive/archive_write_disk_posix.c: In function 'set_time':
/home/ftp/pub/cmake-3.4.1/cmake-3.4.1/Utilities/cmlibarchive/libarchive/archive_write_disk_posix.c:2805:19: error: 'AT_FDCWD' undeclared (first use in this function)
/home/ftp/pub/cmake-3.4.1/cmake-3.4.1/Utilities/cmlibarchive/libarchive/archive_write_disk_posix.c:2805:19: note: each undeclared identifier is reported only once for each function it appears in
/home/ftp/pub/cmake-3.4.1/cmake-3.4.1/Utilities/cmlibarchive/libarchive/archive_write_disk_posix.c:2805:39: error: 'AT_SYMLINK_NOFOLLOW' undeclared (first use in this function)
make[2]: *** [Utilities/cmlibarchive/libarchive/CMakeFiles/cmlibarchive.dir/archive_write_disk_posix.c.o] Error 1
make[1]: *** [Utilities/cmlibarchive/libarchive/CMakeFiles/cmlibarchive.dir/all] Error 2
make: *** [all] Error 2
And the system version:
$ uname -a
Linux DSC_DKLinux 2.6.23 #6 Mon Sep 1 05:27:54 EDT 2008 i586 unknown
$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/gcc-4.7.4/libexec/gcc/i586-pc-linux-gnu/4.7.4/lto-wrapper
Target: i586-pc-linux-gnu
Configured with: ../gcc-4.7.4/configure --prefix=/usr/gcc-4.7.4 --disable-multilib --enable-languages=c,c++
Thread model: posix
gcc version 4.7.4 (GCC)