I want to create my game engine with cmake (thanks to ogre community for their help)
My project have some executables and some libraries(dll/so and lib/a).I want to put all libraries(dynamic and static) in single directory and link executables to them from this directory
Also I want cmake to put dynamic libraries in specific directory(game directory) after their build
CMAKE_LIBRARY_OUTPUT_DIRECTORY - For windows this is only for static libs
CMAKE_RUNTIME_OUTPUT_DIRECTORY - For windows this move all useless file (*.dll.embed.manifest, *.dll.embed.manifest.res ,*.dll.intermediate.manifest , *.dll.resource.txt , *.ilk , *.pdb) but not .lib(file with exportet symbols) that need for linking.
How people do that in their projects
Build multi project with cmake
-
- Greenskin
- Posts: 104
- Joined: Wed Feb 29, 2012 11:50 am
- x 1
-
- Orc
- Posts: 412
- Joined: Thu Jun 04, 2009 3:21 am
- Location: Kalamazoo,MI
- x 38
Re: Build multi project with cmake
For each executable/library I want in my output folder, I use the following to get it to my bin folder:
SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
I have a configuration file for my executable files, so I also copy a fresh one of those to the bin folder as well with the following command:
add_custom_command(TARGET my_exe_name
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/my_exe_name.conf ${PROJECT_BINARY_DIR}/bin/$(ConfigurationName)
)
Hope that gives you some ideas.
SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
I have a configuration file for my executable files, so I also copy a fresh one of those to the bin folder as well with the following command:
add_custom_command(TARGET my_exe_name
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/my_exe_name.conf ${PROJECT_BINARY_DIR}/bin/$(ConfigurationName)
)
Hope that gives you some ideas.
-
- Greenskin
- Posts: 104
- Joined: Wed Feb 29, 2012 11:50 am
- x 1
Re: Build multi project with cmake
10x but I'm new to cmake and don't know how to use add_custom_command.
Search in documentation but can't get it at 100%
Search in documentation but can't get it at 100%
-
- Greenskin
- Posts: 104
- Joined: Wed Feb 29, 2012 11:50 am
- x 1
Re: Build multi project with cmake
I think that I get it 

-
- Halfling
- Posts: 94
- Joined: Mon Dec 01, 2008 2:04 pm
- Location: Germany
- x 1
Re: Build multi project with cmake
It is actually a better solution to use the INSTALL command from cmake and create a install target after compilation. If you want to link e.g. one of your libraries to an executable project of yours, you would use something like the following:
This will create a "<your-lib-target>.cmake" file in your install target's location in the "lib" directory, which can then be used in the CMakeLists.txt file of your executable project which is intended to use the library.
The directory where your install target is copied to, can be specified with the cmake install prefix.
Hope that helps
Thoran
Code: Select all
INSTALL(TARGETS <your-lib-target>
EXPORT <your-lib-target>
RUNTIME DESTINATION "bin"
LIBRARY DESTINATION "lib"
ARCHIVE DESTINATION "lib")
INSTALL(EXPORT <your-lib-target> DESTINATION "lib")
The directory where your install target is copied to, can be specified with the cmake install prefix.
Hope that helps
Thoran