最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

visual studio code - VSCode CMake configure does not generate CMakeCache.txt from CMakeLists.txt - Stack Overflow

programmeradmin3浏览0评论

I have the following structure:

|-CMakeLists.txt
 -src/
    |- CMakeLists.txt

Top-level CMakeLists.txt:

cmake_minimum_required(VERSION 3.30.3 FATAL_ERROR)

set(CMAKE_SYSTEM_VERSION 10.0 CACHE STRING "" FORCE)
set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Sets debug build by default")

# ###############################################################################
# Global compiler options
# ###############################################################################
if("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU")
    message("-- Setting GNU options from top-level CMakeLists.txt")
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++23 -Os" CACHE STRING "CXX build flags")
    set(CMAKE_CXX_FLAGS_DEBUG "-ggdb3 -Og" CACHE STRING "Debug build flags")
    set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG" CACHE STRING "Release build flags")
endif()

set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

project(MyProject CXX)
<snip>

src/CMakeLists.txt does not defined those variable values. I remove buid/CMakeCache.txt and run cmake configure to regenerate the cache and don't see the values udpated in the generated cache file at all, even if I include FORCE in the set(). I configure using VSCode CTRL+SHFT+P. Here is the configure output in the IDE:

[main] Configuring project: MyProject 
[proc] Executing command: /usr/bin/cmake -DCMAKE_BUILD_TYPE:STRING=Debug -Dgtest_build_samples:STRING=ON -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -DCMAKE_C_COMPILER:FILEPATH=/usr/bin/gcc -DCMAKE_CXX_COMPILER:FILEPATH=/usr/bin/g++ --no-warn-unused-cli -S/usr/src/MyProject -B/usr/src/MyProject/build -G Ninja
[cmake] x64 architecture in use
[cmake] Not searching for unused variables given on the command line.
[cmake] -- Setting GNU options
[cmake] -- Configuring done (0.0s)
[cmake] -- Generating done (0.0s)
[cmake] -- Build files have been written to: /usr/src/MyProject/build

What happens? What do I miss?

发布评论

评论列表(0)

  1. 暂无评论