Having CMake put generated binaries in a specific directory structure with assets

前端 未结 1 1018
南笙
南笙 2021-02-03 13:09

My project\'s directory structure is basically as follows:

root/src

root/assets

root/library

I currently have CMake set up to compile the source,

相关标签:
1条回答
  • 2021-02-03 13:52

    Here's a simple example with a structure like yours:

    • root/src/main.cpp (only source file)
    • root/assets (where I want the executable to go)

    Here's the cmake file:

    PROJECT(HelloCMake)
    SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${HelloCMake_SOURCE_DIR}/assets)
    add_executable (HelloCMake src/main.cpp) 
    

    When I build against this using Visual Studio I get the output placed in root/assets/debug. I'd have to dig to figure out how to get rid of the extra configuration folder (debug). Not perfect, but hopefully that gets you on the right track.

    Edit...Even better:

    INSTALL(TARGETS HelloCMake DESTINATION ${HelloCMake_SOURCE_DIR}/assets)
    
    0 讨论(0)
提交回复
热议问题