Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Move cmake release and debug folder

I'm a beginner in Cmake and try to compile a library with my makefile. After hours and hours of research, all is good and compiles fines in visual studio. But it stills a problem for ouput folders. I explain.

I want to have this structure of folders at the end :

-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, ...

But when i try to make this tree, CMake add some "release" and "debug" folders after my bin folder. Like this following example :

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

How i can fix it ? or try to overide like this maybe :

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

I've search on web but have not find any answer.

Here is my CMakeLists.txt file :

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      
)

And here is my structure folder :

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

Thanks

Edit :

So i try to make something like you say, but it doesn't create folder i specifiy :

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})
like image 218
Algorys Avatar asked Nov 27 '25 05:11

Algorys


1 Answers

So i found my answer by myself. I think i've not explain correctly for my first question. It was for just remove the folder after build. The following commands are working :

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

Normally, all the files are created in /bin.

like image 147
Algorys Avatar answered Nov 28 '25 17:11

Algorys



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!