Building Apache log4cxx with CMake - cmake

I am trying build Apache log4cxx 0.13.0 for mingw in windows platform
I builder and installed apr and apr-util using MSYS2
I downloaded log4cxx source from apache repository
but when configuring with CMake it shows this error:
CMake Error at src/cmake/FindAPR.cmake:17 (message):
apr-1-config --includedir failed with result %1 is not a valid Win32
application
Call Stack (most recent call first):
src/cmake/FindAPR.cmake:35 (_apr_invoke)
CMakeLists.txt:44 (find_package)
CMakeOutput.log

apu-1-config of the apr-util package is actually a *nix shell script.
CMake is trying to run apr-1-config directly but of course Windows has no clue how to execute it.
The solution is execute sh.exe with apr-1-config (and its arguments) as argument(s).
The following patch fixes this issue for me:
patch -ulbf src/cmake/FindAPR.cmake << EOF
## -10,3 +10,3 ##
execute_process(
- COMMAND \${APR_CONFIG_EXECUTABLE} \${ARGN}
+ COMMAND sh \${APR_CONFIG_EXECUTABLE} \${ARGN}
OUTPUT_VARIABLE _apr_output
EOF
patch -ulbf src/cmake/FindAPR-Util.cmake << EOF
## -11,3 +11,3 ##
execute_process(
- COMMAND \${APR_UTIL_CONFIG_EXECUTABLE} \${ARGN}
+ COMMAND sh \${APR_UTIL_CONFIG_EXECUTABLE} \${ARGN}
OUTPUT_VARIABLE _apr_output
EOF
I have updated my winlibs build script (which is mostly MSYS2 shell commands) so it now builds the most recent Apache Log4cxx 0.13.0. Besides this issue I had to add a few more workarounds though...

Related

Got "No preprocessor test for "Intel"" when configure a project with CMake

I have a problem when cmake launch first program test.
In fact I launch this command (docker container from mcr.microsoft.com/windows:1809-AMD64) :
cmake.exe -B Build_Windows -DTarget=Windows -DCMAKE_BUILD_TYPE=Debug -G "Ninja" -DCodeCoverage=OFF -DCMAKE_C_COMPILER=C:/workdir/compiler/mingw-w64-7.3.0/bin/gcc.exe -DCMAKE_CXX_COMPILER=C:/workdir/compiler/mingw-w64-7.3.0/bin/g++.exe -S .
I have this result :
CMake Error at C:/workdir/compiler/cmake-3.14.0-win64-x64/share/cmake-3.14/Modules/cmakecompileriddetection.cmake:111 (message):
No preprocessor test for "Intel"
Call Stack (most recent call first):
C:/workdir/compiler/cmake-3.14.0-win64-x64/share/cmake-3.14/Modules/cmakedeterminecompilerid.cmake:151 (compiler_id_detection)
C:/workdir/compiler/cmake-3.14.0-win64-x64/share/cmake-3.14/Modules/cmakedeterminecompilerid.cmake:170 (CMAKE_DETERMINE_COMPILER_ID_WRITE)
C:/workdir/compiler/cmake-3.14.0-win64-x64/share/cmake-3.14/Modules/cmakedeterminecompilerid.cmake:31 (CMAKE_DETERMINE_COMPILER_ID_BUILD)
C:/workdir/compiler/cmake-3.14.0-win64-x64/share/cmake-3.14/Modules/cmakedetermineccompiler.cmake:113 (CMAKE_DETERMINE_COMPILER_ID)
CMakeLists.txt:2 (project)
When open CMakeErrorLog.txt:
The target system is: Windows - -
The host system is: Windows - 10.0.17763 - AMD64
I don't understand why, all path compilers are ok.

How to force CMake to use a special version of Protobuf installed on system?

I want to set Protobuf_INCLUDE_DIRS to a directory of my choosing, however, I am not sure how to do that.
$ locate FindProtobuf.cmake
/usr/share/cmake-3.16/Modules/FindProtobuf.cmake
I can see that in FindProtobuf.cmake, we have these:
if(Protobuf_FOUND)
set(Protobuf_INCLUDE_DIRS ${Protobuf_INCLUDE_DIR})
endif()
I want it to be set to the second option here:
$ which -a protoc
/home/mona/anaconda3/bin/protoc
/usr/local/bin/protoc
However, it is set to the first option /home/mona/anaconda3/bin/protoc despite forcing it in ~/.bashrc to second option: /usr/local/bin/protoc using below command: alias protoc=/usr/local/bin/protoc
The version that my program requires is 3.6.1 and alias protoc=/usr/local/bin/protoc assures that. However, ProtobufCMake forces the path to be /home/mona/anaconda3/bin/protoc and that version is 3.13.0.
A bit about the problem I am facing. I am using openpose and for installing it in Ubuntu 20.04, I am using CMake. It requires the protobuf version to be 3.6.1.
More on here https://github.com/CMU-Perceptual-Computing-Lab/openpose/issues/1817
Here are the messages:
CMake Error at /usr/share/cmake-3.16/Modules/FindProtobuf.cmake:469 (file):
file STRINGS file "/usr/include/google/protobuf/stubs/common.h" cannot be
read.
Call Stack (most recent call first):
CMakeLists.txt:429 (find_package)
CMake Error at /usr/share/cmake-3.16/Modules/FindProtobuf.cmake:475 (math):
math cannot parse the expression: " / 1000000": syntax error, unexpected
exp_DIVIDE (2).
Call Stack (most recent call first):
CMakeLists.txt:429 (find_package)
CMake Error at /usr/share/cmake-3.16/Modules/FindProtobuf.cmake:476 (math):
math cannot parse the expression: " / 1000 % 1000": syntax error,
unexpected exp_DIVIDE (2).
Call Stack (most recent call first):
CMakeLists.txt:429 (find_package)
CMake Error at /usr/share/cmake-3.16/Modules/FindProtobuf.cmake:477 (math):
math cannot parse the expression: " % 1000": syntax error, unexpected
exp_MOD (2).
Call Stack (most recent call first):
CMakeLists.txt:429 (find_package)
CMake Warning at /usr/share/cmake-3.16/Modules/FindProtobuf.cmake:499 (message):
Protobuf compiler version 3.13.0 doesn't match library version
ERROR.ERROR.ERROR
Call Stack (most recent call first):
CMakeLists.txt:429 (find_package)
Not sure how exactly do what I wanted to do above, but a hack to get CMake work for OpenPose is using Python venv and comment the anaconda python activation lines in ~/.bashrc:
Now, cmake-gui .. throws no error:
GCC detected, adding compile flags
GCC detected, adding compile flags
Building with CUDA.
CUDA detected: 10.1
Added CUDA NVCC flags for: sm_75
cuDNN not found
Found gflags (include: /usr/include, library: /usr/lib/x86_64-linux-gnu/libgflags.so)
Found glog (include: /usr/include, library: /usr/lib/x86_64-linux-gnu/libglog.so)
Caffe will be downloaded from source now. NOTE: This process might take several minutes depending
on your internet connection.
Caffe has already been downloaded.
HEAD is now at 1807aada Added Ampere arch's (CUDA11)
Caffe will be built from source now.
Download the models.
Downloading BODY_25 model...
Model already exists.
Not downloading body (COCO) model
Not downloading body (MPI) model
Downloading face model...
Model already exists.
Downloading hand model...
Model already exists.
Models Downloaded.
Configuring done
I have this in ~/.bashrc:
# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
##__conda_setup="$('/home/mona/anaconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
##if [ $? -eq 0 ]; then
## eval "$__conda_setup"
##else
## if [ -f "/home/mona/anaconda3/etc/profile.d/conda.sh" ]; then
## . "/home/mona/anaconda3/etc/profile.d/conda.sh"
## else
## export PATH="/home/mona/anaconda3/bin:$PATH"
## fi
##fi
and installed the following in Ubuntu 20.04:
$ sudo apt-get install python3
$ sudo apt-get install python3-venv
also, do this in ~/.bashrc and source it: alias python=python3
$ python -m venv ~/venv/openpose
$ source ~/venv/openpose/bin/activate

Use LLVM in a cmake build

I'm trying to build my own project that use LLVM. I downloaded the source code and the precompiled package on the official web site (last version).
http://releases.llvm.org/download.html
I downloaded :
LLVM source code
Clang for Windows (64-bit)
FYI, I don't build LLVM... only want to use it !
I followed the instruction here :
http://llvm.org/docs/CMake.html#embedding-llvm-in-your-project
in the section : "Embedding LLVM in your project"
So, I added this code :
find_package(LLVM REQUIRED CONFIG)
message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}")
message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}")
message("LLVM_INCLUDE_DIRS=${LLVM_INCLUDE_DIRS}")
message("LLVM_DEFINITIONS=${LLVM_DEFINITIONS}")
But I got several cmake error messages, here is my output :
-- Using LLVMConfig.cmake in: C:\\Luciad_src\\libs\\LLVM\\cmake\\modules
LLVM_INCLUDE_DIRS=
LLVM_DEFINITIONS=
CMake Error at C:/Luciad_src/libs/LLVM/cmake/modules/LLVM-Config.cmake:31 (list):
list sub-command REMOVE_ITEM requires two or more arguments.
Call Stack (most recent call first):
C:/Luciad_src/libs/LLVM/cmake/modules/LLVM-Config.cmake:256 (is_llvm_target_library)
components/query/CMakeLists.txt:15 (llvm_map_components_to_libnames)
Is there a problem with my script, or the packages I use ? Any idea ?
Thanks for your help
You can have the LLVM as binary or source package.
The binary package does not include CMake support. If you compare both installations (binary on the left, source after building and installing it on the right) you can see the difference:
LLVM-5.0.0-win64.exe
<=> llvm-5.0.1.src.tar.xz (build and installed)
So you need to build and install the source package first to get CMake support. On my Windows machine I needed a cmd shell with administrator rights, a Visual Studio installation, go to the downloaded and extracted sources and do:
> mkdir mybuilddir
> cd mybuilddir
> cmake ..
> cmake --build . --config Release --target INSTALL
If I now use your CMake example I get:
-- Found LLVM 5.0.1
-- Using LLVMConfig.cmake in: C:/Program Files (x86)/LLVM/lib/cmake/llvm
LLVM_INCLUDE_DIRS=C:/Program Files (x86)/LLVM/include
LLVM_DEFINITIONS=-DLLVM_BUILD_GLOBAL_ISEL -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_NONSTDC_NO_WARNINGS -D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS -DUNICODE -D_UNICODE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
-- Configuring done

VTK install error cannot find libvtkCommonCore-6.3.so.1

I'm trying to install VTK but I'm getting the following error
CMake Error at Common/Core/cmake_install.cmake:47 (file):
file INSTALL cannot find
"/home/VTK-6.3.0/VTKBuild/lib/libvtkCommonCore-6.3.so.1".
Call Stack (most recent call first):
cmake_install.cmake:100 (include)
These are the steps I followed
cd VTKBuild
cmake ..\
-D"CMAKE_INSTALL_PREFIX:PATH=/home/VTK-6.3.0/VTKBuild"
make
make install
Can anyone point me to what might be going wrong
I had to turn off shared library option, these are the configuration I used to build VTK
mkdir VTKBuild
cd VTKBuild
cmake ..\
-DCMAKE_INSTALL_PREFIX=/home/VTK-6.3.0/VTKBuild \
-DBUILD_SHARED_LIBS:BOOL=OFF \
-DCMAKE_BUILD_TYPE=Release \
-DVTK_USE_SYSTEM_ZLIB:BOOL=ON
make
make install

Unknown CMake command "CHECK_INCLUDE_FILE_CXX"

I tried running cmake to generate the build tools for linux on vmime with the latest source from git hub, it generated the following errors. Thoughts??
vmime$ /usr/local/bin/cmake -G "Unix Makefiles"
CMake Error at CMakeLists.txt:20 (INCLUDE):
include could not find load file:
CheckIncludeFileCxx
-- Build type: Debug
CMake Error at CMakeLists.txt:452 (CHECK_INCLUDE_FILE_CXX):
Unknown CMake command "CHECK_INCLUDE_FILE_CXX".
-- Configuring incomplete, errors occurred!
In your CMakeLists.txt at line 20, you have
include(CheckIncludeFileCxx)
This should be
include(CheckIncludeFileCXX)
^^--- Uppercase
Once CheckIncludeFileCXX is properly included, the error on line 452 should also disappear, since the file defines the function CHECK_INCLUDE_FILE_CXX.
It has probably only been tested on Windows; since Windows filenames are case-insensitive this would have worked.