Skip to content

Instantly share code, notes, and snippets.

@dirk-thomas
Last active May 6, 2016 18:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dirk-thomas/585e2fc90da969206114134b9adc6348 to your computer and use it in GitHub Desktop.
Save dirk-thomas/585e2fc90da969206114134b9adc6348 to your computer and use it in GitHub Desktop.
Visual Studio dependencies issue
cmake_minimum_required(VERSION 3.4)
project(foo)
add_custom_target(
gen
SOURCES "${CMAKE_CURRENT_BINARY_DIR}/lib.cpp"
COMMENT "Custom target"
)
add_custom_command(
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/lib.cpp"
COMMAND "python" "-c" "import time; print('// ' + str(time.time()))" ">" "${CMAKE_CURRENT_BINARY_DIR}/lib.cpp"
COMMENT "Custom command generating the source file..."
VERBATIM
)
add_library(
lib1 SHARED
"${CMAKE_CURRENT_BINARY_DIR}/lib.cpp"
)
add_dependencies(
lib1
gen
)
add_library(
lib2 SHARED
"${CMAKE_CURRENT_BINARY_DIR}/lib.cpp"
)
add_dependencies(
lib2
gen
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment