CMake Compiler not set - c++

CMake Error: CMAKE_Project_COMPILER not set, after EnableLanguage
I Get this Error after writing cmake ..
This is my CMakeLists.txt
set(CMAKE_CXX_COMPILER "C:/mingw64/bin/g++")
set(CMAKE_C_COMPILER "C:/mingw64/bin/gcc")
project(CXX Project)
add_subdirectory(glfw/)
add_executable(${PROJECT_NAME} Main.cpp)
target_include_directories(${PROJECT_NAME} PUBLIC glfw)
target_link_libraries(${PROJECT_NAME} PUBLIC glfw)```
And this is my Complete Error
PS C:\Users\david\Documents\Idle\Project\build> cmake ..
CMake Error at CMakeLists.txt:6 (project):
Running
'nmake' '-?'
failed with:
Das System kann die angegebene Datei nicht finden
CMake Error: CMAKE_Project_COMPILER not set, after EnableLanguage
-- Configuring incomplete, errors occurred!
See also "C:/Users/david/Documents/Idle/Project/build/CMakeFiles/CMakeOutput.log".

You're using the project command in the wrong way. It should be
project(Project CXX)
That's why CMake is looking for CMAKE_Project_COMPILER instead of CMAKE_CXX_COMPILER.

As you can see in your error message cmake is trying to generate build files for nmake, the visual studio build system. What you are trying to setup is a makefile based build system with mingw. Therefore you should specify the generator directly:
cmake .. -G "MinGW Makefiles"

For "CMake Error: CMAKE_Project_COMPILER not set, after EnableLanguage"
Another possible problem is we need to execute cmake in e.g c:\users\xxx
and can't execute in c:\xxxx

Related

Emscripten emcmake on win10, error when Including X11 support

I am working on a relatively simple c++ project, on windows 10.
Everything works fine when compiling to a Windows executable. But I have issues when trying to compile to Webassembly.
From Emscripten docs there, at least for windows, the procedure seems to be :
emcmake cmake .
# then
emmake make
but when I execute :
emcmake cmake .
I get this error:
configure: cmake .
-DCMAKE_TOOLCHAIN_FILE=C:\gui2one\CODE\emsdk\upstream\emscripten\cmake\Modules\Platform\Emscripten.cmake
-DCMAKE_CROSSCOMPILING_EMULATOR=C:/gui2one/CODE/emsdk/node/14.18.2_64bit/bin/node.exe;
--experimental-wasm-bulk-memory;--experimental-wasm-threads -G "MinGW Makefiles"
-- Including X11 support
CMake Error at C:/cmake-3.19.5-win64-x64/share/cmake-3.19/Modules/FindPackageHandleStandardArgs.cmake:218 (message):
Could NOT find X11 (missing: X11_X11_LIB)
Call Stack (most recent call first):
C:/cmake-3.19.5-win64-x64/share/cmake-3.19/Modules/FindPackageHandleStandardArgs.cmake:582 (_FPHSA_FAILURE_MESSAGE)
C:/cmake-3.19.5-win64-x64/share/cmake-3.19/Modules/FindX11.cmake:437 (find_package_handle_standard_args)
vendor/glfw/src/CMakeLists.txt:190 (find_package)
I tried to install libX11 using cygwin, but Cmake is still unable to find it.
I must say I feel lost in cross-compiling land ...
How can I make X11 available to Cmake ?
Here is the CmakeLists.txt for this project :
cmake_minimum_required(VERSION 3.2)
set (CMAKE_CXX_STANDARD 17)
project(Orbitals)
add_definitions(-DOGL_DEBUG)
include_directories(
cpp/
vendor/glad/include
cpp/Render
cpp/Objects
vendor/spdlog/include
vendor/glad/include
vendor/glad/include/glad
C:/gui2one/CODE/emsdk/upstream/emscripten/system/include
# ${EMSCRIPTEN_PATH}/upstream/emscripten/system/include/GLES3
)
set(RENDER_SRC
cpp/Render/Camera.cpp
cpp/Render/OpenGLBuffer.cpp
cpp/Render/OpenGLFrameBuffer.cpp
cpp/Render/OpenGLHDRSkybox.cpp
cpp/Render/OpenGLHDRTexture.cpp
cpp/Render/OpenGLShader.cpp
cpp/Render/OpenGLSkybox.cpp
cpp/Render/OpenGLTexture.cpp
cpp/Render/OpenGLVertexArray.cpp
)
add_executable(${PROJECT_NAME}
cpp/main.cpp
cpp/stb_image.cpp
cpp/Timer.cpp
cpp/pch.h
cpp/opengl_debug.h
cpp/Log.h
cpp/Log.cpp
cpp/RNDGenerator.cpp
cpp/Algorithms/PoissonDiscSampling.cpp
cpp/Mesh/Mesh.cpp
cpp/Mesh/MeshUtils.cpp
cpp/Mesh/MeshImporter.cpp
cpp/Mesh/PointCloud.cpp
cpp/Objects/Entity3d.cpp
cpp/Objects/LightObject.cpp
cpp/Objects/MeshObject.cpp
${RENDER_SRC}
)
set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 17)
target_include_directories(${PROJECT_NAME} PUBLIC
vendor/glfw/include
vendor/glad/include
vendor/glm
vendor/spdlog/include
vendor/
cpp/Render
C:/gui2one/CODE/emsdk/upstream/emscripten/system/include
)
# GLFW
add_subdirectory(vendor/glfw)
include_directories(vendor/glfw/include)
target_link_libraries(${PROJECT_NAME} glfw ${GLFW_LIBRARIES})
# GLAD
add_subdirectory(vendor/glad)
include_directories(vendor/glad/include)
target_link_libraries(${PROJECT_NAME} glad ${GLAD_LIBRARIES})
# ASSIMP
add_subdirectory(vendor/assimp)
include_directories(vendor/assimp/include)
target_link_libraries(${PROJECT_NAME} assimp ${ASSIMP_LIBRARIES})
You do not need to include glfw directory when compiling with emscripten. GLFW3 is already included in the emscripten library, so you do not need to compile it. You can simply omit add_subdirectory when building for HTML5 like so:
# GLFW
if (NOT EMSCRIPTEN)
add_subdirectory(vendor/glfw)
endif()
include_directories(vendor/glfw/include)
target_link_libraries(${PROJECT_NAME} glfw ${GLFW_LIBRARIES})
Also make sure you add USE_GLFW=3 link flag for the target you want to compile:
set_target_properties(target
PROPERTIES SUFFIX ".html"
LINK_FLAGS " --bind -s WASM=0 -s MIN_WEBGL_VERSION=1 -s ABORT_ON_WASM_EXCEPTIONS=1 -g2 -s USE_GLFW=3")

CMake Error: Please set them or make sure they are set and tested correctly in the CMake files: QUICKFIX_LIBRARY linked by target "run" in directory

I try to build a project on CLion with Cygwin and I got this error :
-- Found Boost: /usr/include (found version "1.66.0") found components: system thread regex iostreams chrono date_time atomic
-- Configuring done
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
QUICKFIX_LIBRARY
linked by target "run_engine" in directory /cygdrive/c/Users/33671/Desktop/main_program
-- Generating done
CMake Generate step failed. Build files cannot be regenerated correctly.
I try to generate the .exe fail but nothing appeared because of this error.
Any idea ?
So I changed the Path of QUICKFIX_LIBRARY in the CmakeCache.txt and then I don't have the error. But in reality it's still not finding it because once it's written in CMakeCache.txt, it doesn't check anymore if it's really include or not.
My lib is located like this : project_name/exchanges/quickfix/lib/cygquickfix-16.dll.
The lib is cygquickfix-16.dll.
I added a control message to see if he found or not the library.
I still have an ERROR at the end.
cmake_minimum_required(VERSION 3.5)
project(test)
set(CMAKE_CXX_STANDARD 14)
SET(Boost_USE_STATIC_LIBS OFF)
SET(Boost_USE_MULTITHREAD ON)
SET(CMAKE_PREFIX_PATH /lib/)
FIND_PACKAGE(Boost REQUIRED COMPONENTS system thread regex iostreams)# 1.66.0
IF(Boost_FOUND)
INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS})
LINK_DIRECTORIES(${Boost_LIBRARY_DIRS})
ENDIF(Boost_FOUND)
SET(USED_LIBS ${Boost_SYSTEM_LIBRARY} ${Boost_THREAD_LIBRARY} ${Boost_REGEX_LIBRARY} ${Boost_IOSTREAMS_LIBRARY})
add_executable(run_engine main_poco.cpp ....)
include_directories(.)
include_directories(./exchanges/quickfix/include)
find_library(QUICKFIX_LIBRARY quickfix HINTS ./exchanges/quickfix/lib)
message("-- QUICKFIX_LIBRARY: ${QUICKFIX_LIBRARY}")
target_link_libraries(run_engine ${QUICKFIX_LIBRARY} -lPocoDataMySql -l...)
And then I get this in CMake Debug :
C:\Users\33671\AppData\Local\JetBrains\CLion2022.1\cygwin_cmake\bin\cmake.exe -DCMAKE_BUILD_TYPE=Debug -DCMAKE_MAKE_PROGRAM=/usr/bin/make.exe -DCMAKE_C_COMPILER=/usr/bin/gcc.exe -DCMAKE_CXX_COMPILER=/usr/bin/c++.exe -G "CodeBlocks - Unix Makefiles" -S /cygdrive/c/Users/33671/Desktop/project -B /cygdrive/c/Users/33671/Desktop/project/cmake-build-debug
-- QUICKFIX_LIBRARY: QUICKFIX_LIBRARY-NOTFOUND
-- Configuring done
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
QUICKFIX_LIBRARY
linked by target "run_engine" in directory /cygdrive/c/Users/33671/Desktop/project
-- Generating done
CMake Generate step failed. Build files cannot be regenerated correctly.

How to fix error: "CMake Error at CMakeLists.txt:6 (project):" [duplicate]

This question already has answers here:
Can't get CMAKE to compile a project
(1 answer)
Error while configuring CMake project: Running 'nmake' '-?' failed
(2 answers)
Closed 1 year ago.
I am new to using CMake. I installed the Windows binaries for CMake 3.22 and added it to my path during the setup process. I created a simple directory to do a test build, created and moved into a "build" directory, and ran "cmake .." but get the following error:
PS C:\test> cd build
PS C:\test\build> cmake ..
-- Building for: NMake Makefiles
CMake Error at CMakeLists.txt:9 (project):
Running
'nmake' '-?'
failed with:
The system cannot find the file specified
-- Configuring incomplete, errors occurred!
See also "C:/test/build/CMakeFiles/CMakeOutput.log".
Here is the CMakeLists.txt:
# Set Compiler Path
SET(CMAKE_C_COMPILER C:/MinGW/bin/gcc)
SET(CMAKE_CXX_COMPILER C:/MinGW/bin/g++)
# Set Minimum Required CMake Version
cmake_minimum_required(VERSION 3.22)
# set the project name and version
project(test_build VERSION 1.0)
# Specify the C++ standard
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED True)
# add the executable
add_executable(test test.cpp)
The CMakeOutput.log file constains:
The system is: Windows - 10.0.19043 - AMD64
Thanks for the help!

project (PROJECT) called with incorrect number of arguments [CMake] [MAYA 2020]

as you can see my CMakeLists.txt content is :
I should add this that my MAYA version is 2020 but my devkit is 2020 hotfix 1
could it be the problem?
I don't know why the Autodesk documentation or other companies are not complete.
they just explain things generally not in detail
cmake_minimum_required(VERSION 2.8)
project()
set(PROJECT_NAME test)
include($ENV{DEVKIT_LOCATION}/cmake/pluginEntry.cmake)
set(RESOURCES_FILES myResource.xpm)
set(MEL_FILES
test.mel)
set(SOURCE_FILES
test.cpp
${MEL_FILES}
)
set(LIBRARIES
OpenMaya Foundation
)
build_plugin()
when I wanna generate in CMake I get these Errors:
CMake Error at CMakeLists.txt:2 (project):
project PROJECT called with incorrect number of arguments
CMake Warning (dev) at M:/Autodesk_Maya_2020_DEVKIT_Windows_Hotfix_1/devkitBase/cmake/pluginEntry.cmake:204 (add_library):
ADD_LIBRARY called with SHARED option but the target platform does not
support dynamic linking. Building a STATIC library instead. This may lead
to problems.
Call Stack (most recent call first):
CMakeLists.txt:25 (build_plugin)
This warning is for project developers. Use -Wno-dev to suppress it.
CMake Error: Error required internal CMake variable not set, cmake may not be built correctly.
Missing variable is:
CMAKE_FIND_LIBRARY_PREFIXES
CMake Error: Error required internal CMake variable not set, cmake may not be built correctly.
Missing variable is:
CMAKE_FIND_LIBRARY_SUFFIXES
CMake Error: Error required internal CMake variable not set, cmake may not be built correctly.
Missing variable is:
CMAKE_FIND_LIBRARY_PREFIXES
CMake Error: Error required internal CMake variable not set, cmake may not be built correctly.
Missing variable is:
CMAKE_FIND_LIBRARY_SUFFIXES
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
Foundation_PATH
linked by target "test" in directory C:/Users/amink/Desktop/API Project
OpenMaya_PATH
linked by target "test" in directory C:/Users/amink/Desktop/API Project
project() shouldn't be empty project(test) solved my problem
cmake_minimum_required(VERSION 2.8)
project(test)
set(PROJECT_NAME test)
include($ENV{DEVKIT_LOCATION}/cmake/pluginEntry.cmake)
set(RESOURCES_FILES myResource.xpm)
set(MEL_FILES
test.mel)
set(SOURCE_FILES
test.cpp
${MEL_FILES}
)
set(LIBRARIES
OpenMaya Foundation
)
build_plugin()

'OpenCV required but some headers or libs not found' with CLion, MinGW-64, CMake on Windows 10

I've been trying for a few days to correctly setup OpenCV with CLion with little success, so asking on SO.
Here's what my CMakeLists looks like:
cmake_minimum_required(VERSION 3.12)
project(ocv_test)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
find_package(OpenCV REQUIRED)
set(SOURCE_FILES main.cpp)
add_executable(ocv_test ${SOURCE_FILES})
include_directories(${OpenCV_INCLUDE_DIRS})
target_link_libraries(ocv_test ${OpenCV_LIBS})
Here's the error I get:
"C:\Program Files\JetBrains\CLion 2018.2.2\bin\cmake\win\bin\cmake.exe" -DCMAKE_BUILD_TYPE=Debug -G "CodeBlocks - MinGW Makefiles" C:\Users\Owner\CLionProjects\ocv-test
Could not find OpenCV_CORE_INCLUDE_DIR
Could not find OpenCV_HIGHGUI_INCLUDE_DIR
Include dir: OFF
CMake Error at C:/Program Files/JetBrains/CLion 2018.2.2/bin/cmake/win/share/cmake-3.12/Modules/FindOpenCV.cmake:220 (MESSAGE):
OpenCV required but some headers or libs not found. Please specify it's
location with OpenCV_ROOT_DIR env. variable.
Call Stack (most recent call first):
CMakeLists.txt:6 (find_package)
-- Configuring incomplete, errors occurred!
See also "C:/Users/Owner/CLionProjects/ocv-test/cmake-build-debug/CMakeFiles/CMakeOutput.log".
I primarily followed these steps from another SO answer, but here are the steps:
Installed MinGW-64
Architecture: x86_64, Threads: posix, Exception: sjlj
Installed CMake 3.12.2 x64 msi
In System variables, set/create the following:
_CMAKE_HOME (C:\Program Files (x86)\CMake)
_MINGW_HOME (C:\mingw\mingw64)
Then, add the following to Path variable:
%_CMAKE_HOME%\bin
%_MINGW_HOME%\bin
Download OpenCV 3.4.3, and Extract to:
C:\opencv\opencv-3.4.3
Using CMake, Configure w/ MinGW Makefiles and specifying Native compilers:
C: C:/mingw/mingw64/bin/x86_64-w64-mingw32-gcc.exe
C++: C:/mingw/mingw64/bin/x86_64-w64-mingw32-g++.exe
Then, Generate (without Tests, Docs, Python, WITH_IPP, WITH_MSMF) to:
C:_dev_sw\opencv\opencv-3.4.3\build_mingw
Run mingw32-make, then mingw32-make install in C:_dev_sw\opencv\opencv-3.4.3\build_mingw
In System variables, set/create the following:
_OPENCV_HOME (C:\opencv\opencv-3.4.3\build_mingw\install\x64\mingw)
Then, add the following to Path variable:
%_OPENCV_HOME%\bin
Add FindOpenCV.cmake to:
C:\Program Files\JetBrains\CLion 2018.2.2\bin\cmake\win\share\cmake-3.12\Modules
Create new C++ executable project in CLion (ocv-test)
Update MakeLists.txt file (see above)
Reload MakeLists.txt and get errors shown above
I tried to update the CMakeLists as below, but still same errors:
cmake_minimum_required(VERSION 3.12)
project(ocv_test)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
# Where to find CMake modules and OpenCV
set(OpenCV_DIR "C:\\opencv\\opencv-3.4.3\\build_mingw\\install")
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/")
find_package(OpenCV REQUIRED)
include_directories(${OpenCV_INCLUDE_DIRS})
add_executable(ocv_test main.cpp)
# add libs you need
set(OpenCV_LIBS opencv_core opencv_imgproc opencv_highgui opencv_imgcodecs)
# linking
target_link_libraries(ocv_test ${OpenCV_LIBS})
Unlike this SO answer, I do not see OpenCV_DIR name in my CMake build. Also, I tried updating _OPENCV_HOME to OpenCV_ROOT_DIR (as error says), but that didn't work either.
Does anything seem off?
===
Edit 1:
FindOpenCV was the issue (so skip step 11). Setting the OPENCV_DIR var in CMakeLists fixed the errors, and built successfully (Thanks Tsyvarev!).
I'm not sure if setting OPENCV_DIR in CMakeLists will be an issue if the project is ran on another PC and/or OS, so I added OPENCV_DIR entry (pointing to /install directory) into CMake GUI, Repeated steps 6-8, created new but similar CLion project, and got the following error:
CMake Error at CMakeLists.txt:10 (find_package):
By not providing "FindOpenCV.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "OpenCV", but
CMake did not find one.
Could not find a package configuration file provided by "OpenCV" with any
of the following names:
OpenCVConfig.cmake
opencv-config.cmake
Add the installation prefix of "OpenCV" to CMAKE_PREFIX_PATH or set
"OpenCV_DIR" to a directory containing one of the above files. If "OpenCV"
provides a separate development package or SDK, be sure it has been
installed.
Again, this is fixed if I set the OPENCV_DIR variable. But how can it be avoided since it's already configured in GUI?