I'm trying to develop an engine for private use, I'm using CMake because I intend to make it multiplatform in the future, but an error started to appear that I never came across before, I tried to change project(IEngine) to project(IEngine CXX) as said in other questions from stack overflow, but the error persists, here's my CMakeLists
cmake_minimum_required(VERSION 3.16.2)
project(IEngine)
find_package(Vulkan REQUIRED)
file(GLOB_RECURSE SRC_RENDERER
"${IEngine_SOURCE_DIR}/src/Renderer/*.cpp"
"${IEngine_SOURCE_DIR}/src/Renderer/*.hpp"
"${IEngine_SOURCE_DIR}/src/Renderer/*.h")
source_group("Renderer" FILES ${SRC_RENDERER})
add_library(IEngine STATIC ${SRC_RENDERER})
if(WIN32)
target_compile_definitions(IEngine PRIVATE VK_USE_PLATFORM_WIN32_KHR)
endif()
target_include_directories(IEngine PRIVATE Vulkan::Vulkan)
target_link_libraries(IEngine Vulkan::Vulkan)
The output:
Selecting Windows SDK version 10.0.18362.0 to target Windows 10.0.18363.
The C compiler identification is MSVC 19.24.28315.0
The CXX compiler identification is MSVC 19.24.28315.0
Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.24.28314/bin/Hostx64/x64/cl.exe
Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.24.28314/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/Community/VC/Tools/MSVC/14.24.28314/bin/Hostx64/x64/cl.exe
Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.24.28314/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
Found Vulkan: A:/VulkanSDK/1.2.131.1/Lib/vulkan-1.lib
Configuring done
CMake Error: CMake can not determine linker language for target: IEngine
Generating done
I've had this error many times :( Add this to your CMakeLists.txt:
set_target_properties(IEngine PROPERTIES LINKER_LANGUAGE CXX)
Related
I am new in c++
The cmakelist.txt file dont give me a Makefile
-- Building for: Visual Studio 16 2019
-- Selecting Windows SDK version 10.0.19041.0 to target Windows 10.0.22000.
-- The C compiler identification is MSVC 19.29.30140.0
-- The CXX compiler identification is MSVC 19.29.30140.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
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Users/JohnSmith/Documents/Hello/build
I dont know how to change the compiler to G++
this is the cmake
cmake_minimum_required(VERSION 3.0)
set(CMAKE_C_COMPILER "gcc")
set(CMAKE_CXX_COMPILER "g++")
project(HelLo)
add_executable(Hello main.cpp hello.cpp)
I am on windows , Thanks for help
(I can compile with g++ and gcc just cmakefile dont work )
First, make sure you've installed gcc/g++ under Windows (either CygWin or MinGW). Remove the set commands from your CMakelists.txt. Then in a CygWin/MinGW shell use the following command to generate the Makefile:
CC=gcc CXX=c++ cmake ..
cmake -G "Unix Makefiles" ..
I am trying to write a simple clang AST cursor traveler.
https://github.com/dyhe83/clang-AST-cursor-traveler
This following cmake code works fine on Linux.
PROJECT(traveler)
FIND_LIBRARY(LIBCLANG_PATH
clang HINTS /usr/local/lib/
)
ADD_EXECUTABLE(traveler
traveler.cpp
)
TARGET_LINK_LIBRARIES(traveler
${LIBCLANG_PATH}
)
I also want to run this example on windows.
My LLVM is build in "C:\Program Files (x86)\LLVM"
But after I changed the FIND_LIBRARY part of CMakeLists.txt.
FIND_LIBRARY(LIBCLANG_PATH
clang HINTS "C:\\Program Files (x86)\\LLVM\\lib"
)
Some error occurs:
D:\WorkSpace\C\clang-AST-cursor-traveler\build>cmake ..
-- Building for: Visual Studio 15 2017
-- The C compiler identification is MSVC 19.16.27025.1
-- The CXX compiler identification is MSVC 19.16.27025.1
-- 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
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:
LIBCLANG_PATH
linked by target "traveler" in directory D:/WorkSpace/C/clang-AST-cursor-traveler/src
-- Configuring incomplete, errors occurred!
See also "D:/WorkSpace/C/clang-AST-cursor-traveler/build/CMakeFiles/CMakeOutput.log".
And "C:\Program Files (x86)\LLVM\lib" have the libraries.
Does anyone know where is the correct clang library path on windows??
Try to set env virable in windows.
I mean the place where you add/edit PATH env virables
LIBCLANG_PATH=C:\Program Files (x86)\LLVM\lib
I built PCL on windows using VCPKG(MS Visual studio 2017). I am trying to build a CPP application with PCL using cmake 3.12 with the following CMakelists.txt.
cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
project(compute)
find_package(PCL 1.5 REQUIRED)
include_directories(${PCL_INCLUDE_DIRS})
link_directories(${PCL_LIBRARY_DIRS})
add_definitions(${PCL_DEFINITIONS})
add_executable (compute compute.cpp)
target_link_libraries (compute ${PCL_LIBRARIES})
I also set the following environment variables.
set PCL_INCLUDE_DIRS="C:\vcpkg-pcl\vcpkg-master\installed\x64-windows\include\pcl"
SET PCL_LIBRARY_DIRS="C:\vcpkg-pcl\vcpkg-master\installed\x64-windows\lib"
set PCL_LIBRARIES="pcl_common_release.lib;pcl_features_release.lib;pcl_filters_release.lib;pcl_io_ply_release.lib;pcl_io_release.lib"
I initially got an error saying it is unable to find the file FindPCL.cmake and eventually PCLConfig.cmake or PCL-Config.cmake. I set the environment variable
set PCL_DIR=C:\vcpkg-pcl\vcpkg-master\installed\x64-windows\share\pcl
where the PCLConfig.cmake is installed. It was able to detect the file. However,
it is unable to detect PCL(pcl_report_not_found) with the following error.
c:\PCL-Program>cmake .
-- Building for: Visual Studio 15 2017
-- Selecting Windows SDK version 10.0.17763.0 to target Windows 10.0.17134.
-- The C compiler identification is MSVC 19.16.27023.1
-- The CXX compiler identification is MSVC 19.16.27023.1
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Professional/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x86/cl.exe
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Professional/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/Professional/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x86/cl.exe
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Professional/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
-- Could NOT find Eigen (missing: EIGEN_INCLUDE_DIR)
CMake Error at C:/vcpkg-pcl/vcpkg-master/installed/x64-windows/share/pcl/PCLConfig.cmake:56 (message):
common is required but eigen was not found
Call Stack (most recent call first):
C:/vcpkg-pcl/vcpkg-master/installed/x64-windows/share/pcl/PCLConfig.cmake:356 (pcl_report_not_found)
C:/vcpkg-pcl/vcpkg-master/installed/x64-windows/share/pcl/PCLConfig.cmake:526 (find_external_library)
CMakeLists.txt:5 (find_package)
-- Configuring incomplete, errors occurred!
See also "C:/PCL-Program/CMakeFiles/CMakeOutput.log".
c:\PCL-Program>set EIGEN_INCLUDE_DIR
EIGEN_INCLUDE_DIR=C:\vcpkg-pcl\vcpkg-master\installed\x64-windows\include\Eigen
Even after setting the environment variable for EIGEN_INCLUDE_DIR, I am still getting the same error. Please let me know if I am following the right way.
Thanks!
So, i set up my Cloin/SFML project like this : configure SFML for clion (windows)
and added the SFML_ROOT variable, and then it works exactly once, and every time i try too run it after the first, i get this error(gam is the project name, it is set correctly in the CMakeLists.txt file):
mingw32-make.exe: *** No rule to make target 'gam'. Stop.
How do i get it to work more than once?(It might be something as stupid as me clicking the wrong button to run this thing. I´m new to Clion and cmake)
CMakeLists.txt:
cmake_minimum_required(VERSION 3.12)
project(gam)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(SOURCE_FILES main.cpp)
add_executable(gam ${SOURCE_FILES})
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake_modules")
find_package(SFML REQUIRED system window graphics network audio)
if (SFML_FOUND)
include_directories(${SFML_INCLUDE_DIR})
target_link_libraries(gam ${SFML_LIBRARIES})
endif()
output of CMake when project is first initialized:
"C:\Program Files\JetBrains\CLion 2018.2.4\bin\cmake\win\bin\cmake.exe" -DCMAKE_BUILD_TYPE=Debug -G "CodeBlocks - MinGW Makefiles" D:\programierzeug\c++\test
-- The C compiler identification is GNU 8.1.0
-- The CXX compiler identification is GNU 8.1.0
-- Check for working C compiler: C:/Program Files (x86)/mingw-w64/i686-8.1.0-posix-dwarf-rt_v6-rev0/mingw32/bin/gcc.exe
-- Check for working C compiler: C:/Program Files (x86)/mingw-w64/i686-8.1.0-posix-dwarf-rt_v6-rev0/mingw32/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:/Program Files (x86)/mingw-w64/i686-8.1.0-posix-dwarf-rt_v6-rev0/mingw32/bin/g++.exe
-- Check for working CXX compiler: C:/Program Files (x86)/mingw-w64/i686-8.1.0-posix-dwarf-rt_v6-rev0/mingw32/bin/g++.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: D:/programierzeug/c++/test/cmake-build-debug
[Finished]
output of CMake when reloading project:
"C:\Program Files\JetBrains\CLion 2018.2.4\bin\cmake\win\bin\cmake.exe" -DCMAKE_BUILD_TYPE=Debug -G "CodeBlocks - MinGW Makefiles" D:\programierzeug\c++\test
-- Configuring done
-- Generating done
-- Build files have been written to: D:/programierzeug/c++/test/cmake-build-debug
[Finished]
I'm currently getting this error while trying to configure a project on CMAKE using Visual Studio 15 2017 Win64:
The C compiler identification is MSVC 19.11.25547.0
The CXX compiler identification is MSVC 19.11.25547.0
Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.11.25503/bin/Hostx86/x64/cl.exe
Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.11.25503/bin/Hostx86/x64/cl.exe -- works
Detecting C compiler ABI info
Detecting C compiler ABI info - done
Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.11.25503/bin/Hostx86/x64/cl.exe
Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.11.25503/bin/Hostx86/x64/cl.exe -- works
Detecting CXX compiler ABI info
Detecting CXX compiler ABI info - done
Detecting CXX compile features
Detecting CXX compile features - done
Found OpenGL: opengl32
Looking for pthread.h
Looking for pthread.h - not found
Found Threads: TRUE
Using Win32 for window creation
Using WGL for context creation
Lib glbinding
Performing Test COMPILER_HAS_DEPRECATED_ATTR
Performing Test COMPILER_HAS_DEPRECATED_ATTR - Failed
Performing Test COMPILER_HAS_DEPRECATED
Performing Test COMPILER_HAS_DEPRECATED - Success
Configuring done
I've used this compiler to generate another project and it still works.
Here is the code relevant to the new CMakeLists.txt:
project(ms3d_td3)
cmake_minimum_required(VERSION 3.2.0)
add_subdirectory(ext/glfw)
add_subdirectory(ext/glbinding)
include_directories(ext/glfw/include)
include_directories(ext/glbinding/include)
include_directories(ext/eigen3)
if(APPLE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -stdlib=libc++")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
endif()
set(SRC_FILES
src/main.cpp
src/viewer.cpp
src/viewer.h
src/shader.cpp
src/shader.h
src/opengl.h)
add_definitions(-DDATA_DIR="${PROJECT_SOURCE_DIR}/data")
add_executable(ms3d_td3 ${SRC_FILES})
target_link_libraries(ms3d_td3 glfw ${GLFW_LIBRARIES} glbinding)
Under Visual Studio 2017 I get a CMAKE_C_COMPILER not set after EnableLanguage. I tried to set it manually to the VisualStudio 2017 compiler but no success. Any ideas?
Another person had a similar problem and solved it by upgrading Visual Studio a while ago so I'm guessing this is coming from somewhere else... :
Compiler failing on C++11 instructions in a Visual Studio project configured with cmake
Thanks!
To require compiler support for the [[decprecated]] attribute, use target_compile_features and specify the cxx_attribute_deprecated feature. For example:
add_executable(foo foo.cpp)
target_compile_features(foo PRIVATE cxx_attribute_deprecated)
If you need to conditionally test for this so that you can configure a header file, use check_cxx_source_compiles.