[CMake] installing without building the whole project
Dominik Szczerba
dominik at itis.ethz.ch
Fri Jun 10 05:02:06 EDT 2011
Many thanks for the clarifications!
Dominik
On Thu, Jun 9, 2011 at 11:18 PM, Michael Hertling <mhertling at online.de> wrote:
> On 06/09/2011 03:34 PM, Dominik Szczerba wrote:
>> Hi,
>>
>> I have a big project with several subfolders. In one subfolder's cmake
>> file I have e.g.
>>
>> INSTALL(TARGETS test DESTINATION ${CMAKE_INSTALL_PREFIX} CONFIGURATIONS RELEASE)
>>
>> Now when I call "make install" on linux or build "INSTALL" project in
>> MSVC the whole project is built prior to installation of "test". How
>> would I force to only build "test" in this case?
>>
>> Many thanks for any hints,
>> Dominik
>
> Since the general "install" target always depends on the general "all"
> target, you should use a specific "install" target for your binary:
>
> CMAKE_MINIMUM_REQUIRED(VERSION 2.8 FATAL_ERROR)
> PROJECT(INSTALL C)
> SET(CMAKE_VERBOSE_MAKEFILE ON)
> FILE(WRITE ${CMAKE_BINARY_DIR}/main.c "int main(void){return 0;}\n")
> ADD_EXECUTABLE(main main.c)
> INSTALL(TARGETS main
> DESTINATION ${CMAKE_INSTALL_PREFIX}
> CONFIGURATIONS RELEASE)
> ADD_CUSTOM_TARGET(install.main
> ${CMAKE_COMMAND}
> -DBUILD_TYPE=${CMAKE_BUILD_TYPE}
> -P ${CMAKE_BINARY_DIR}/cmake_install.cmake)
> ADD_DEPENDENCIES(install.main main)
>
> The custom target install.main depends on the main target only and
> invokes the cmake_install.cmake script; the desired configuration is
> passed to this script via the BUILD_TYPE parameter, or alternatively
> CMAKE_INSTALL_CONFIG_NAME, i.e. the script does not install anything
> if CMAKE_INSTALL_CONFIG_NAME doesn't match one of the CONFIGURATIONS
> in the INSTALL() command. This has been tested on *nix, but I assume
> it works similar on Windows; inspect the cmake_install.cmake script
> there to find out which parameter must be passed for configurations
> selection. Note that the custom commands' "generator expressions"
> can be used in custom targets, too - undocumented - so you might
> pass the configuration as $<CONFIGURATION> to the script.
>
> 'hope that helps.
>
> Regards,
>
> Michael
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake
>
>
More information about the CMake
mailing list