I get build errors on Linux using g++, during the object phase, like:
cc1plus: error: too many filenames given; type ‘cc1plus --help’ for usage
cc1plus: fatal error: contournieuw/CMakeFiles/contournieuw.dir/contournieuw.cpp.d: No such file or directory.
The .d file is for dependencies afaik but here somehow (improperly) added as a source file.
The command works after removing it.
I very much would like to know how it got there and even better, how to get rid of it…
I have a root cmakelist.txt and a subdir one, included in the root cmakelists.txt with add_subdirectory(contournieuw).
From the root: cmake -G Ninja -B Debug -DCMAKE_BUILD_TYPE=Debug
At some point, I changed to targets (Debug and Release) and that works.
But I try now to use my cmake project for qtcreate and that requires project() statements in each non-root cmakelists.txt.
I apologize for not having that much experience with cmake. Hopefully it is a simple matter!
I tried vainly to attach.
The full (bad) command is:
/usr/bin/g++ -DNUMTYPE=float -D_CRT_SECURE_NO_WARNINGS -D_DEBUG -D_ITERATOR_DEBUG_LEVEL=0 -D_MBCS -D__CONTOUR__ -I/home/jan/projects/gevers-civiel/contournieuw/../../shapelibport/include -I/home/jan/projects/gevers-civiel/contournieuw/.. -I/home/jan/projects/gevers-civiel/contournieuw/. -g -m64 -std=c++20 -D_FILE_OFFSET_BITS=64 -msse4.1 -mfma -Wno-unknown-pragmas -Wno-reorder -Wno-format-overflow -Wno-missing-field-initializers -o0 -Wextra -MD -MT contournieuw/CMakeFiles/contournieuw.dir/contournieuw.cpp.o -MF contournieuw/CMakeFiles/contournieuw.dir/contournieuw.cpp.o.d -o contournieuw/CMakeFiles/contournieuw.dir/contournieuw.cpp.o -c /home/jan/projects/gevers-civiel/contournieuw/contournieuw.cpp
The root cmakelists.txt:
cmake_minimum_required(VERSION 3.16.0 FATAL_ERROR)
set(CMAKE_SYSTEM_VERSION 10.0 CACHE STRING "" FORCE)
project(gevers-civiel-basis C CXX)
################################################################################
# Specify compiler and add settings for LTO.
################################################################################
set(CMAKE_CXX_COMPILER
"/usr/bin/g++"
CACHE STRING "" FORCE
)
set(CMAKE_AR
"/usr/bin/gcc-ar-14"
CACHE STRING "" FORCE
)
set(CMAKE_RANLIB
"/usr/bin/gcc-ranlib-14"
CACHE STRING "" FORCE
)
################################################################################
# Set target arch type if empty.
################################################################################
if(NOT CMAKE_PLATFORM_NAME)
set(CMAKE_PLATFORM_NAME "x64")
endif()
message("${CMAKE_PLATFORM_NAME} architecture in use")
if(NOT ("${CMAKE_PLATFORM_NAME}" STREQUAL "x64"))
message(FATAL_ERROR "${CMAKE_PLATFORM_NAME} arch is not supported!")
endif()
################################################################################
# Global configuration types
################################################################################
set(CMAKE_CONFIGURATION_TYPES
"Debug"
"Release"
CACHE STRING "" FORCE
)
################################################################################
# Global compiler options
################################################################################
################################################################################
# Global linker options
################################################################################
################################################################################
# Compile flags and macros.
################################################################################
set(MY_COMPILE_FLAGS
"-m64"
"-std=c++20"
"-D_FILE_OFFSET_BITS=64"
"-msse4.1"
"-mfma"
#"-fopenmp" # SPECIFICEER OPENMP PER GEVAL! Iig niet bij contournieuw
"-Wno-unknown-pragmas"
"-Wno-reorder"
"-Wno-format-overflow"
"-Wno-missing-field-initializers"
CACHE STRING "" FORCE
)
set(MY_COMPILE_DEFINITIONS
__CONTOUR__;
_CRT_SECURE_NO_WARNINGS;
NUMTYPE=float;
_MBCS;
${DEFAULT_CXX_EXCEPTION_HANDLING}
CACHE STRING "" FORCE
)
################################################################################
# Common utils
################################################################################
include(CMake/Utils.cmake)
################################################################################
# Additional Global Settings(add specific info there)
################################################################################
include(CMake/GlobalSettingsInclude.cmake OPTIONAL)
################################################################################
# Use solution folders feature
################################################################################
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
################################################################################
# Prepare linking to shapelib, define base path
set(SHAPELIB_BASE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../shapelibport/build/shapelib" CACHE STRING "" FORCE)
# Define the library paths for different configurations
set(SHAPELIB_PATH_DEBUG "${SHAPELIB_BASE_PATH}/static_lib_debug/" CACHE STRING "" FORCE)
set(SHAPELIB_PATH_RELEASE "${SHAPELIB_BASE_PATH}/static_lib/" CACHE STRING "" FORCE)
# Sub-projects
################################################################################
add_subdirectory(contournieuw)
and the subdir cmakelists.txt:
project(contournieuw)
################################################################################
# Source groups
################################################################################
set(Header_Files
"contournieuw.h"
"resource.h"
)
source_group("Header Files" FILES ${Header_Files})
set(Source_Files
"contournieuw.cpp"
)
source_group("Source Files" FILES ${Source_Files})
set(ALL_FILES
${Header_Files}
${Source_Files}
)
set(MY_INCLUDE_DIRECTORIES
"${CMAKE_CURRENT_SOURCE_DIR}/../../shapelibport/include;"
"${CMAKE_CURRENT_SOURCE_DIR}/..;"
"${CMAKE_CURRENT_SOURCE_DIR}/."
CACHE STRING "" FORCE
)
################################################################################
# Target
################################################################################
add_executable(${PROJECT_NAME} ${ALL_FILES})
set(ROOT_NAMESPACE ${PROJECT_NAME})
################################################################################
# Target name
################################################################################
set_target_properties(${PROJECT_NAME} PROPERTIES
OUTPUT_NAME "$<IF:$<CONFIG:Debug>,${PROJECT_NAME}deb,${PROJECT_NAME}64>"
INTERPROCEDURAL_OPTIMIZATION_RELEASE "$<IF:$<CONFIG:Release>,TRUE,FALSE>"
)
################################################################################
# Include directories
################################################################################
target_include_directories(${PROJECT_NAME} PUBLIC ${MY_INCLUDE_DIRECTORIES})
################################################################################
# Compile definitions specific for targets
################################################################################
target_compile_definitions(${PROJECT_NAME} PRIVATE
${MY_COMPILE_DEFINITIONS};
$<$<CONFIG:Release>:NDEBUG>
$<$<CONFIG:Debug>:_DEBUG;_ITERATOR_DEBUG_LEVEL=0>
)
################################################################################
# Compile and link options
################################################################################
target_compile_options(${PROJECT_NAME} PRIVATE
${MY_COMPILE_FLAGS};
$<$<CONFIG:Release>:-O3;-Wall>
#$<$<CONFIG:Debug>:-ggdb;-o0;-Wextra>
$<$<CONFIG:Debug>:-o0;-Wextra>
)
target_link_options(${PROJECT_NAME} PRIVATE
$<$<CONFIG:Release>:-static>
)
################################################################################
set(ADDITIONAL_LIBRARY_DEPENDENCIES shapelib)
################################################################################
message(STATUS "Release Path: ${SHAPELIB_PATH_RELEASE}")
message(STATUS "Debug Path: ${SHAPELIB_PATH_DEBUG}")
target_link_libraries(${PROJECT_NAME} PRIVATE
$<$<CONFIG:Debug>:${SHAPELIB_PATH_DEBUG}/libshapelib.a>
$<$<CONFIG:Release>:${SHAPELIB_PATH_RELEASE}/libshapelib.a>
)