Windows中的cmake要求所有包含目录都小写

时间:2018-09-21 10:09:37

标签: c++ cmake ninja

我遇到一个奇怪的问题,我include_directoriestarget_link_libraries使用的路径必须全部小写。

如果我尝试在项目中将其包含在GLTestBed/src下的子目录下,忍者(甚至内置的VS解决方案)会抛出错误

C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\ninja : error : '../../GLTestBed/src/Mesh.cpp', needed by 'GLTestBed/CMakeFiles/GlTestBed.dir/src/Mesh.cpp.obj', missing and no known rule to make it

Mesh.cpp是我的add_Library指令中添加的第一个文件,如果我删除它会抛出该错误的顶部文件,那么我很确定它不只是该特定文件的错误

但是,如果我将文件夹名称从GLTestBed更改为gltestbed,那么一切都会正确构建

主文件夹(GLParticles)中的CmakeLists.txt

        cmake_minimum_required(VERSION 3.10)
    set(CMAKE_CXX_STANDARD 11)
    project(GLParticles)

    set (glparticlesdir "${CMAKE_CURRENT_SOURCE_DIR}/GLTestBed")

    message ("-----" , ${glparticlesdir}) 

    add_subdirectory(${glparticlesdir})

    add_executable(GLParticles
            src/main.cpp 
            src/ParticleWorld.cpp
            src/ParticleWorld.h
            src/BurstParticleUpdater.cpp
            src/BurstParticleUpdater.h src/SineWaveUpdater.cpp src/SineWaveUpdater.h)

    include_directories(${glparticlesdir}/src)
    include_directories(${glparticlesdir}/ext/glm)

    target_link_libraries(GLParticles
            GlTestBed)

    # SET(CMAKE_CXX_LINK_FLAGS "-framework OpenGL")

和GLTestBed文件夹中的CmakeLists.txt

    cmake_minimum_required(VERSION 3.10)
    project(GlTestBed)

    set(CMAKE_CXX_STANDARD 11)

    find_package(OpenGL REQUIRED)
    #find_package(GLEW REQUIRED)

    message ('--------'  ${OPENGL_LIBRARIES})

    add_Library(GlTestBed
            src/Globals.h
            src/Mesh.cpp
            src/Mesh.h
            src/ResourceManager.cpp
            src/ResourceManager.hpp
            src/Shader.cpp
            src/Shader.h
            src/stb_image.cpp
            src/stb_image.h
            src/Material.h
            src/Engine.cpp src/Engine.h
            src/Particle.cpp
            src/Particle.h
            src/Camera.h
            src/Camera.cpp
            src/ParticleManager.cpp
            src/ParticleManager.h
            src/ParticleUpdater.h)

    target_include_directories(GlTestBed PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/src)
    target_include_directories(GlTestBed PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/ext/glm)

    target_link_libraries(GlTestBed 
        ${OPENGL_LIBRARIES} 
        glew32.lib 
        sfml-graphics.lib
        sfml-window.lib
        sfml-system.lib)

    if(APPLE)
        target_include_directories(GlTestBed PUBLIC
                /usr/local/include)
        target_link_libraries(GlTestBed
                /usr/local/Cellar/glew/2.1.0/lib/libGLEW.2.1.0.dylib
                /usr/local/Cellar/sfml/2.4.2_1/lib/libsfml-window.2.4.2.dylib
                /usr/local/Cellar/sfml/2.4.2_1/lib/libsfml-system.2.4.2.dylib ${OPENGL_LIBRARIES})
    endif()

0 个答案:

没有答案