Manually set the CMake output folder 1
If you want to manually set the global output folder for you whole CMake
project and depending on the output you expect add the following configuration lines in the root CMakeLists.txt
file of your project:
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
In case you wan to specify those folders per target, you can update them as follows:
set_target_properties( target_or_targets PROPERTIES ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin" )
Please note that we are setting the same properties using different variables.
The
CMAKE_ARCHIVE_OUTPUT_DIRECTORY
variable is used to initialize theARCHIVE_OUTPUT_DIRECTORY
property on all the targets.
ARCHIVE_OUTPUT_DIRECTORY
property specifies the directory into which archive target files should be built.
An archive output artifact of a buildsystem target may be:
- The static library file (e.g.
.lib
or.a
) of a static library target created by theadd_library()
command with theSTATIC
option.- On DLL platforms: the import library file (e.g.
.lib
) of a shared library target created by theadd_library()
command with theSHARED
option.- On DLL platforms: the import library file (e.g.
.lib
) of an executable target created by theadd_executable()
command when itsENABLE_EXPORTS
target property is set.
The
CMAKE_LIBRARY_OUTPUT_DIRECTORY
variable is used to initialize theLIBRARY_OUTPUT_DIRECTORY
property on all the targets.
LIBRARY_OUTPUT_DIRECTORY
property specifies the directory into which library target files should be built.
A library output artifact of a buildsystem target may be:
The loadable module file (e.g..dll
or.so
) of a module library target created by theadd_library()
command with theMODULE
option.
On non-DLL platforms: the shared library file (e.g..so
or.dylib
) of a shared shared library target created by theadd_library()
command with theSHARED
option.
The
CMAKE_RUNTIME_OUTPUT_DIRECTORY
variable is used to initialize theRUNTIME_OUTPUT_DIRECTORY
property on all the targets.
RUNTIME_OUTPUT_DIRECTORY
property specifies the directory into which runtime target files should be built.
A runtime output artifact of a buildsystem target may be:
- The executable file (e.g.
.exe
) of an executable target created by theadd_executable()
command.- On DLL platforms: the executable file (e.g.
.dll
) of a shared library target created by theadd_library()
command with theSHARED
option.