I'm trying to run this cmake file on windows
cmake_minimum_required(VERSION 3.8)
set(CMAKE_C_COMPILER "C:/Program Files/LLVM/bin/clang")
set(CMAKE_CXX_COMPILER "C:/Program Files/LLVM/bin/clang++")
set(OPENMP_LIBRARIES "C:/Program Files/LLVM/lib")
set(OPENMP_INCLUDES "C:/Program Files/LLVM/include")
set(OpenMP_C "${CMAKE_C_COMPILER}")
set(OpenMP_C_FLAGS "-fopenmp=libomp -Wno-unused-command-line-argument")
set(OpenMP_C_LIB_NAMES "libomp" "libgomp" "libiomp5")
set(OpenMP_libomp_LIBRARY ${OpenMP_C_LIB_NAMES})
set(OpenMP_libgomp_LIBRARY ${OpenMP_C_LIB_NAMES})
set(OpenMP_libiomp5_LIBRARY ${OpenMP_C_LIB_NAMES})
set(OpenMP_CXX "${CMAKE_CXX_COMPILER}")
set(OpenMP_CXX_FLAGS "-fopenmp=libomp -Wno-unused-command-line-argument")
set(OpenMP_CXX_LIB_NAMES "libomp" "libgomp" "libiomp5")
set(OpenMP_libomp_LIBRARY ${OpenMP_CXX_LIB_NAMES})
set(OpenMP_libgomp_LIBRARY ${OpenMP_CXX_LIB_NAMES})
set(OpenMP_libiomp5_LIBRARY ${OpenMP_CXX_LIB_NAMES})
message("!!!!!!!!!!!!!!!! " ${OpenMP_C_FLAGS} )
find_package(OpenMP REQUIRED)
With this command line parameters:
cmake -G"Visual Studio 15 2017" -T LLVM ..
It is strange that I get the fallowing error even if OpenMP_C_FLAGS is defined according to the output:
-- The C compiler identification is Clang 9.0.0
-- The CXX compiler identification is Clang 9.0.0
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x86/cl.exe
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x86/cl.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x86/cl.exe
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x86/cl.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
!!!!!!!!!!!!!!!! -fopenmp=libomp -Wno-unused-command-line-argument
CMake Error at C:/Program Files/CMake/share/cmake-3.13/Modules/FindPackageHandleStandardArgs.cmake:137 (message):
Could NOT find OpenMP_C (missing: OpenMP_C_FLAGS)
Call Stack (most recent call first):
C:/Program Files/CMake/share/cmake-3.13/Modules/FindPackageHandleStandardArgs.cmake:378 (_FPHSA_FAILURE_MESSAGE)
C:/Program Files/CMake/share/cmake-3.13/Modules/FindOpenMP.cmake:473 (find_package_handle_standard_args)
CMakeLists.txt:25 (find_package)
-- Configuring incomplete, errors occurred!
If I run cmake without -T LLVM flag, then cmake FindOpenMP.cmake runs fine (uses windows compiler). clang doesn't support openmp on windows ?
Related
I'm actualy trying to compile a project on windows with the CMakeList.txt that I used to compile the project on linux.
Unfortunatly when I try to compile with windows powershell, cmake is saying :
cmake . -G "MinGW Makefiles"
-- The C compiler identification is GNU 12.2.0
-- The CXX compiler identification is GNU 12.2.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/msys64/mingw64/bin/gcc.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/msys64/mingw64/bin/g++.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Error at C:/Program Files/CMake/share/cmake-3.26/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
Could NOT find SDL2_image (missing: SDL2_IMAGE_LIBRARIES)
Call Stack (most recent call first):
C:/Program Files/CMake/share/cmake-3.26/Modules/FindPackageHandleStandardArgs.cmake:600 (_FPHSA_FAILURE_MESSAGE)
cmake/FindSDL2_image.cmake:91 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
CMakeLists.txt:12 (find_package)
-- Configuring incomplete, errors occurred!
At the first time it didn't scared me cause I know that I have to download every library and link them to the cmake.
After I download every library like this : screenshot of the files
I tried to link them into my cmake,
firstly adding them to my Environment Variables :screenshot
but that didn't work, he always says "impossible to find SDL2_image when its perfectly working on linux with the cmakeFound...
W/E if someone knows how to compile or add a library to cmake on windows it could be insane for me.
I am trying to compile SAGA-GIS API on Windows using the following instructions https://sourceforge.net/p/saga-gis/wiki/Compiling%20SAGA%20on%20Windows/
I have followed the compilation step-by-step and gotten to the point of compiling SAGA. As I'm an inexperienced user of CMake, I user CMake-GUI and it's instructions for compiling. However, I keep running into this error
Selecting Windows SDK version 10.0.19041.0 to target Windows 10.0.19044.
The C compiler identification is MSVC 19.29.30143.0
The CXX compiler identification is MSVC 19.29.30143.0
Detecting C compiler ABI info
Detecting C compiler ABI info - done
Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/BuildTools/VC/Tools/MSVC/14.29.30133/bin/Hostx64/x64/cl.exe - skipped
Detecting C compile features
Detecting C compile features - done
Detecting CXX compiler ABI info
Detecting CXX compiler ABI info - done
Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/BuildTools/VC/Tools/MSVC/14.29.30133/bin/Hostx64/x64/cl.exe - skipped
Detecting CXX compile features
Detecting CXX compile features - done
folder: saga
Found Git: C:/Program Files/Git/cmd/git.exe (found version "2.31.1.windows.1")
GIT_BRANCH: master
VERSON_STRING: 8.4.0
VERSON_FULL_STRING: 8.4.0-256+17a31eb88
compile with OpenMP optimizations
folder: src
folder: accessories
folder: saga_core
CMake Error at C:/Program Files/CMake/share/cmake-3.24/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
Could NOT find wxWidgets (missing: wxWidgets_LIBRARIES
wxWidgets_INCLUDE_DIRS)
Call Stack (most recent call first):
C:/Program Files/CMake/share/cmake-3.24/Modules/FindPackageHandleStandardArgs.cmake:594 (_FPHSA_FAILURE_MESSAGE)
C:/Program Files/CMake/share/cmake-3.24/Modules/FindwxWidgets.cmake:977 (find_package_handle_standard_args)
src/saga_core/CMakeLists.txt:16 (find_package)
Configuring incomplete, errors occurred!
See also "C:/saga-gis-code/build/CMakeFiles/CMakeOutput.log".
See screenshot:
I am trying to build llvm with MSVC 2017 as below:
git clone --branch llvmorg-9.0.1 https://github.com/llvm/llvm-project.git
cd llvm-project
mkdir build && cd build
cmake -DLLVM_ENABLE_PROJECTS=clang -G "Visual Studio 15 2017" -A x64 -Thost=x64 ..\llvm -DCMAKE_INSTALL_PREFIX=<PATH_WHERE_LLVM_WILL_BE_INSTALLED>
cmake --build . --target INSTALL --config Release
but even I specific -G "Visual Studio 15 2017" and above is running in MSVC 2017 native prompt, it compiler version identified as MSVC 2019 as below:
>cmake -DLLVM_ENABLE_PROJECTS=clang -G "Visual Studio 15 2017" -A x64 -Thost=x64 ..\llvm -DCMAKE_INSTALL_PREFIX="C:/lib/llvm"
-- Selecting Windows SDK version 10.0.18362.0 to target Windows 10.0.18363.
-- The C compiler identification is MSVC 19.16.27045.0
-- The CXX compiler identification is MSVC 19.16.27045.0
-- The ASM compiler identification is MSVC
-- Found assembler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/Hostx64/x64/cl.exe
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/Hostx64/x64/cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/Hostx64/x64/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
You can see in the console output that the Visual Studio 2017 compiler was indeed selected. There is no issue. Here are the lines in question:
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/Hostx64/x64/cl.exe - skipped
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/Hostx64/x64/cl.exe - skipped
I am using MSVC command line tools to try to compile a simple c++ based program for arm/arm64 on a x64 machine. Even after using the toolchain file, the compiler definition is not getting updated and the default compiler for host is being used. Please read further for more information on the issue.
Testcase:
#include <iostream>
using namespace std;
int main()
{
cout << "Hello world!" << endl;
}
CMakelists.txt:
cmake_minimum_required(VERSION 3.14.3)
project(hello C CXX ASM)
enable_language(ASM)
add_executable(hello hello.cpp)
Toolchain file:
cmake_minimum_required(VERSION 3.14.3)
set(CMAKE_CROSSCOMPILING 1)
set(CMAKE_SYSTEM_NAME Windows)
set(CMAKE_SYSTEM_PROCESSOR ARM)
set(CMAKE_SYSTEM_VERSION 10.0)
set(CMAKE_C_COMPILER "C:/Program Files (x86)/Microsoft Visual Studio/2019/BuildTools/VC/Tools/MSVC/14.28.29333/bin/Hostx64/arm/cl.exe")
set(CMAKE_CXX_COMPILER "C:/Program Files (x86)/Microsoft Visual Studio/2019/BuildTools/VC/Tools/MSVC/14.28.29333/bin/Hostx64/arm/cl.exe")
set(CMAKE_ASM_COMPILER "C:/Program Files (x86)/Microsoft Visual Studio/2019/BuildTools/VC/Tools/MSVC/14.28.29333/bin/Hostx64/arm/cl.exe")
The command I used to build this:
cmake.exe -S C:\hello -B C:\hello\output_dir.cmake -DCMAKE_TOOLCHAIN_FILE=C:\hello\Toolchain.cmake
With the above configuration, I am able to build a x64 based application but not a cross compiled ARM based one. From console logs, I see that the c and c++ compiler definition is not overwritten but ASM compiler is overwritten using the toolchain file.
-- Building for: Visual Studio 16 2019
-- Selecting Windows SDK version 10.0.18362.0 to target Windows 10.0.
-- The C compiler identification is MSVC 19.28.29336.0
-- The CXX compiler identification is MSVC 19.28.29336.0
-- The ASM compiler identification is MSVC
-- Found assembler: C:/Program Files (x86)/Microsoft Visual Studio/2019/BuildTools/VC/Tools/MSVC/14.28.29333/bin/Hostx64/arm/cl.exe
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/BuildTools/VC/Tools/MSVC/14.28.29333/bin/Hostx64/x64/cl.exe
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/BuildTools/VC/Tools/MSVC/14.28.29333/bin/Hostx64/x64/cl.exe - works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/BuildTools/VC/Tools/MSVC/14.28.29333/bin/Hostx64/x64/cl.exe
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/BuildTools/VC/Tools/MSVC/14.28.29333/bin/Hostx64/x64/cl.exe - works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: C:/hello/output_dir.cmake
I am not sure what is missing in this configuration. Can anyone please help from their experience?
Thanks for your answers.
Using set(CMAKE_GENERATOR_PLATFORM ARM64 CACHE INTERNAL "") in my toolchain file worked for me, following are the logs picking correct compiler:
> -- Building for: Visual Studio 16 2019
> -- Selecting Windows SDK version 10.0.18362.0 to target Windows 10.0.
> -- The C compiler identification is MSVC 19.28.29336.0
> -- The CXX compiler identification is MSVC 19.28.29336.0
> -- The ASM compiler identification is MSVC
> -- Found assembler: C:/Program Files (x86)/Microsoft Visual Studio/2019/BuildTools/VC/Tools/MSVC/14.28.29333/bin/Hostx64/arm/cl.exe
> -- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual
> Studio/2019/BuildTools/VC/Tools/MSVC/14.28.29333/bin/Hostx64/arm64/cl.exe
> -- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual
> Studio/2019/BuildTools/VC/Tools/MSVC/14.28.29333/bin/Hostx64/arm64/cl.exe
> - works
> -- Detecting C compiler ABI info
> -- Detecting C compiler ABI info - done
> -- Detecting C compile features
> -- Detecting C compile features - done
> -- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual
> Studio/2019/BuildTools/VC/Tools/MSVC/14.28.29333/bin/Hostx64/arm64/cl.exe
> -- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual
> Studio/2019/BuildTools/VC/Tools/MSVC/14.28.29333/bin/Hostx64/arm64/cl.exe
> - works
> -- Detecting CXX compiler ABI info
> -- Detecting CXX compiler ABI info - done
> -- Detecting CXX compile features
> -- Detecting CXX compile features - done
> -- Configuring done
> -- Generating done
> -- Build files have been written to: C:/hello/output_dir.cmake
I am new to Cmake and Boost. I am now working on a program using cmake and need help.
System: windows 7
Cmake version: 3.16.0-rc1
Boost version: boost_1_71_0. And boost is installed through .exe file.
Gcc version: 4.8.1(rev5, Built by MinGW-W64 project)
Visual studio: vs 2015
When I run cmake .. in build dir, no error occurs. The output is:
The C compiler identification is MSVC 19.0.24215.1
The CXX compiler identification is MSVC 19.0.24215.1
Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/cl.exe
Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/cl.exe -- works
Detecting C compiler ABI info
Detecting C compiler ABI info - done
Detecting C compile features
Detecting C compile features - done
Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/cl.exe
Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/cl.exe -- works
Detecting CXX compiler ABI info
Detecting CXX compiler ABI info - done
Detecting CXX compile features
Detecting CXX compile features - done
Found Boost: C:/local/boost_1_71_0 (found version "1.71.0")
Boost_Found Success!
Found OpenCV: C:/Users/gph/opencv/binaries (found version "3.4.5")
Found OpenCV: C:/Users/gph/opencv/binaries (found version "3.4.5") found components: core highgui imgproc videoio
Configuring done
But I want to use minGW to compile, so When I rum cmake -G "MinGW Makefiles", error occured saying "Could NOT find Boost (missing: Boost_INCLUDE_DIR)". The output is:
The C compiler identification is GNU 4.8.1
The CXX compiler identification is GNU 4.8.1
Check for working C compiler: C:/MinGW/bin/gcc.exe
Check for working C compiler: C:/MinGW/bin/gcc.exe -- works
Detecting C compiler ABI info
Detecting C compiler ABI info - done
Detecting C compile features
Detecting C compile features - done
Check for working CXX compiler: C:/MinGW/bin/g++.exe
Check for working CXX compiler: C:/MinGW/bin/g++.exe -- works
Detecting CXX compiler ABI info
Detecting CXX compiler ABI info - done
Detecting CXX compile features
Detecting CXX compile features - done
CMake Error at C:/Users/gph/cmake/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:146 (message):
Could NOT find Boost (missing: Boost_INCLUDE_DIR)
Call Stack (most recent call first):
C:/Users/gph/cmake/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:393 (_FPHSA_FAILURE_MESSAGE)
C:/Users/gph/cmake/share/cmake-3.16/Modules/FindBoost.cmake:2162 (find_package_handle_standard_args)
CMakeLists.txt:34 (find_package)
Configuring incomplete, errors occurred!
See also "C:/Users/gph/Desktop/libvibe++/build/CMakeFiles/CMakeOutput.log".
How to solve the error when running cmake -G "MinGW Makefiles"? Thanks guys!
I solved this by adding sentence set(BOOST_ROOT C:/local/boost_1_71_0) before find_package(Boost REQUIRED) LOL...
But I still wonder why I need to add this.
You can also set variables BOOST_ROOT during the creation of the cmake project (or CMake options in CLion and other IDE). For example:
mkdir buildtest; cd buildtest
cmake -DBOOST_ROOT=/you_path_to_boost/boost ..
cmake --build . -- -j 4
I had a similar problem on Linux/Manjaro. Make sure you have boost installed, more specifically the boost development headers. I had the boost runtime libraries installed but not the headers. I installed those sudo pacman -S boost and it fixed the problem for me.
After I solved this problem, thanks to ToughMind here, these problems occurred to me: _Boost_COMPONENT_DEPENDENCIES and _Boost_MISSING_DEPENDENCIES. What helped me was to update to the newest cmake verison and I got the answer from here: CMake finds Boost but the imported targets not available for Boost version