How to enable makefile makefile after completing a goal?

Given the following minimal example.

cmake_minimum_required(VERSION 2.8)
project(include_test)

add_custom_command(OUTPUT OtherCMakeLists.txt
    COMMAND "${CMAKE_CURRENT_BINARY_DIR}/create_other_cmakelists")
add_custom_target(do_something DEPENDS OtherCMakeLists.txt)

What needs to be done do_somethinghere, first create OtherCMakeLists.txt. Now suppose you do_somethinghave to do something else later, for example. compilation of some code. I would like that when goals from something else are fulfilled, it CMakeLists.txtwill behave as if it OtherCMakeLists.txtwere included in include.

Is it possible?

As an example, why this may be useful: OtherCMakeLists.txtmay add some compiler flags that affect further compilation.

+4
source share
2 answers

, CMakeLists.txt / include CMake CMakeLists.txt

, include " " ( cmake CMakeLists.txt), (CMakeLists.txt) " " ( make )

+1

add_custom_command :

  • add_custom_command(OUTPUT ...) , CMakeLists.txt.
  • add_custom_command(TARGET ...), . PRE_BUILD, PRE_LINK POST_BUILD. , , ...

, .

CMake, :

+1

Source: https://habr.com/ru/post/1589141/


All Articles