Why CMake adds unnecessary libraries to Visual studio project?

后端 未结 1 1414
借酒劲吻你
借酒劲吻你 2021-01-18 00:32

I have this simple CMake file

cmake_minimum_required(VERSION 2.8)
project(test)
set(SOURCES source.cpp)
add_executable(test ${SOURCES})

whe

相关标签:
1条回答
  • 2021-01-18 00:59

    As commented by @Vertexwahn those are the defaults defined from CMake by CMAKE_CXX_STANDARD_LIBRARIES_INIT in CMakeCXXInformation.cmake.

    I just wanted to add a simple AdditionalDependencies macro replacement found here:

    cmake_minimum_required(VERSION 3.0)
    
    file(
        WRITE "${CMAKE_BINARY_DIR}/MakeRulesOverwrite.cmake"
    [=[
        if (MSVC)        
            set(CMAKE_CXX_STANDARD_LIBRARIES_INIT "%(AdditionalDependencies)")
        endif()
    ]=]
    )
    set(CMAKE_USER_MAKE_RULES_OVERRIDE "${CMAKE_BINARY_DIR}/MakeRulesOverwrite.cmake")
    
    project(test)
    ...
    

    References

    • CMAKE_USER_MAKE_RULES_OVERRIDE
    • what is %(AdditionalDependencies) macro?
    • Change default value of CMAKE_CXX_FLAGS_DEBUG and friends in CMake
    0 讨论(0)
提交回复
热议问题