簡體   English   中英

移動cmake release和debug文件夾

[英]Move cmake release and debug folder

我是Cmake的初學者,並嘗試使用我的makefile編譯庫。 經過數小時和數小時的研究,一切都很好,並在視覺工作室編造罰款。 但是對於輸出文件夾來說仍然存在問題。 我解釋。

我希望最后有這種文件夾結構:

-vc_2013_x64      < for platform x64 in release
--bin
---my.dll, my.lib, ...

-vc_2013_x64d     < for platform x64 in debug
--bin
---my.dll, my.lib, ...

但是當我嘗試制作這個樹時,CMake在我的bin文件夾后添加一些“release”和“debug”文件夾。 像下面這樣的例子:

-vc_2013_x64
--bin
*---release* --> NOT WANTED FOLDER
----my.dll, my.lib, ...

我怎么解決它? 或者嘗試像這樣覆蓋:

-release
--vc_2013_x64
---bin
----my.dll, my.lib, ...

我在網上搜索但沒找到任何答案。

這是我的CMakeLists.txt文件:

cmake_minimum_required(VERSION 2.8)

#Configuration du projet

project(core CXX)

#add definitions
set(LIBRARY_OUTPUT_PATH /vc2013_x64/bin/)
set(LIBRARY_OUTPUT_DIRECTORY ../essai)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4")
add_definitions(-D_UNICODE -D_USRDLL -DCORE_EXPORTS)
add_definitions("/Gm")#"/GL" "/Gy" 


#remove_definitions
add_definitions(-UCMAKE_INTDIR="Release")

#inclusions
#include_directories(include/*)
#file( GLOB_RECURSE source_files src/*)

#Configuration de la librairie
add_library(

    core

    SHARED

    src/asserts.h
    src/errors.h
    src/filepath.h
    src/memory.h
    src/resources.h
    src/stdafx.h
    src/streams.h
    src/string.h
    src/system.h
    src/variants.h

    src/filepath.cpp
    src/main.cpp
    src/memory.cpp
    src/resources.cpp
    src/stdafx.cpp
    src/streams.cpp
    src/string.cpp
    src/system.cpp      
)

這是我的結構文件夾:

-core
--src           -> contains my .h and .cpp files 
--win32         -> solution files of visual studios
--cmake_build   -> contains my files generated by cmake
--CMakeLists.txt

謝謝

編輯:

所以我嘗試制作像你說的那樣,但它不會創建我指定的文件夾:

project(core CXX)

#add definitions

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4")
add_definitions(-D_UNICODE -D_USRDLL -DCORE_EXPORTS)
add_definitions("/Gm")#"/GL" "/Gy" 

#remove_definitions
add_definitions(-UCMAKE_INTDIR="Release")


#Configuration de la librairie
add_library(

        core

        SHARED

    src/asserts.h
    src/errors.h
    src/filepath.h
    src/memory.h
    src/resources.h
    src/stdafx.h
    src/streams.h
    src/string.h
    src/system.h
    src/variants.h

    src/filepath.cpp
    src/main.cpp
    src/memory.cpp
    src/resources.cpp
    src/stdafx.cpp
    src/streams.cpp
    src/string.cpp
    src/system.cpp      
)

set(DIR_NAME "/vc2013_x64")
set(LIBRARY_OUTPUT_PATH_RELEASE "${DIR_NAME}/bin")
set(LIBRARY_OUTPUT_PATH_DEBUG "${DIR_NAME}d/bin")
install (TARGETS core DESTINATION ${LIBRARY_OUTPUT_PATH_RELEASE} CONFIGURATIONS Release)
install (TARGETS core DESTINATION ${LIBRARY_OUTPUT_PATH_DEBUG})

所以我自己找到了答案。 我想我的第一個問題沒有正確解釋。 它只是為了在構建后刪除文件夾。 以下命令正在運行:

set(BIN_PATH "../path") -> define your principal path
set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG "${BIN_PATH}/bin/" ) ->define path for archive
set( CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG "${BIN_PATH}/bin/" ) ->define path for Library
set( CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG "${BIN_PATH}/bin/" ) ->define path for Runtime

通常,所有文件都在/ bin中創建。

您可以使用的是CMAKE的安裝目標。 它允許您定義安裝目標,您可以在其中復制構建庫和相關文件。 對於您的示例,這可能看起來像這樣:

add_library(core SHARED
    ...
)

set(DIR_NAME "/vc2013_x64")
set(LIBRARY_OUTPUT_PATH_RELEASE "${DIR_NAME}/bin")
set(LIBRARY_OUTPUT_PATH_DEBUG "${DIR_NAME}d/bin")

install (TARGETS core DESTINATION ${LIBRARY_OUTPUT_PATH_RELEASE} CONFIGURATIONS Release)
install (TARGETS core DESTINATION ${LIBRARY_OUTPUT_PATH_DEBUG} CONFIGURATIONS Debug)

然后,您可以在構建環境中運行安裝目標,並將文件復制到您希望的位置。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM