0

I have this code that runs during configuration time:

if (NOT EXISTS "${PROJECT_BINARY_DIR}/tmpdir/")
  file (MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/tmpdir/")
  message ("Generating tmpdir directory")
endif ()

How do I implement the above code but in build time?

Joel
  • 1,805
  • 1
  • 22
  • 22

1 Answers1

1

How do I implement the above code but in build time?

It depends on when you exactly need this directory. For instance if you need it before executable foo compiled, you can use add_custom_target and add_dependencies:

add_custom_target(
    make_temp
    "${CMAKE_COMMAND}" -E make_directory "${PROJECT_BINARY_DIR}/tmpdir"
    COMMENT "Create 'tmpdir'"
)

add_executable(foo ...)
add_dependencies(foo make_temp)