Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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