Skip to content

Commit

Permalink
Merge pull request #969 from dimacurrentai/cmake_current_build
Browse files Browse the repository at this point in the history
  • Loading branch information
dkorolev authored Mar 12, 2024
2 parents 82e44f3 + d1113a5 commit eea24f7
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions cmake/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,11 @@ add_custom_command(OUTPUT "${C5T_DEP_DIR_current}/current_build.h"
ARGS "${C5T_DEP_DIR_current}/current_build.h"
DEPENDS src)

# TODO(dkorolev): [re-]add `/inc/` after the respective `mkdir -p` command is live in `C5T/Current:stable`.
add_custom_target(C5T_CURRENT_BUILD_INFO_H_TARGET ALL DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/current_build_info.h") # TODO add inc/
add_custom_target(C5T_CURRENT_BUILD_INFO_H_TARGET ALL DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/inc/current_build_info.h")

add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/current_build_info.h" # TODO add inc/
add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/inc/current_build_info.h"
COMMAND "${C5T_DEP_DIR_current}/scripts/gen-current-build.sh"
ARGS "${CMAKE_CURRENT_BINARY_DIR}/current_build_info.h" # TODO add inc/
ARGS "${CMAKE_CURRENT_BINARY_DIR}/inc/current_build_info.h"
DEPENDS src)

set(C5T_LIBRARIES "Threads::Threads" "C5T")
Expand All @@ -81,7 +80,7 @@ foreach(SHARED_LIBRARY_SOURCE_FILE ${BINARY_SOURCE_FILES})
add_dependencies(${SHARED_LIBRARY_TARGET_NAME} C5T_CURRENT_BUILD_INFO_H_TARGET)
# TODO(dkorolev): Might be worth it to `grep` this `dlib_*.cc` source file for required library dependencies.
target_compile_definitions(${SHARED_LIBRARY_TARGET_NAME} PRIVATE C5T_CMAKE_PROJECT)
target_include_directories(${SHARED_LIBRARY_TARGET_NAME} PRIVATE "${CMAKE_CURRENT_BINARY_DIR}") # TODO add inc/
target_include_directories(${SHARED_LIBRARY_TARGET_NAME} PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/inc")
target_link_libraries(${SHARED_LIBRARY_TARGET_NAME} PRIVATE "${C5T_LIBRARIES}")
endforeach()

Expand All @@ -93,7 +92,7 @@ foreach(LIBRARY_SOURCE_FILE ${LIBRARY_SOURCE_FILES})
add_library(${LIBRARY_TARGET_NAME} "${LIBRARY_SOURCE_FILE}")
add_dependencies(${LIBRARY_TARGET_NAME} C5T_CURRENT_BUILD_INFO_H_TARGET)
target_compile_definitions(${LIBRARY_TARGET_NAME} PRIVATE C5T_CMAKE_PROJECT)
target_include_directories(${LIBRARY_TARGET_NAME} PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/") # TODO add inc/
target_include_directories(${LIBRARY_TARGET_NAME} PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/inc")
target_link_libraries(${LIBRARY_TARGET_NAME} PRIVATE "${C5T_LIBRARIES}")
list(APPEND ALL_LIBRARIES "${LIBRARY_TARGET_NAME}")
endforeach()
Expand All @@ -106,7 +105,7 @@ foreach(BINARY_SOURCE_FILE ${BINARY_SOURCE_FILES})
add_executable(${BINARY_TARGET_NAME} "${BINARY_SOURCE_FILE}")
add_dependencies(${BINARY_TARGET_NAME} C5T_CURRENT_BUILD_INFO_H_TARGET)
target_compile_definitions(${BINARY_TARGET_NAME} PRIVATE C5T_CMAKE_PROJECT)
target_include_directories(${BINARY_TARGET_NAME} PRIVATE "${CMAKE_CURRENT_BINARY_DIR}") # TODO add inc/
target_include_directories(${BINARY_TARGET_NAME} PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/inc")
target_link_libraries(${BINARY_TARGET_NAME} PRIVATE "${ALL_LIBRARIES}")
endif()
endforeach()
Expand All @@ -118,7 +117,7 @@ foreach(TEST_SOURCE_FILE ${TEST_SOURCE_FILES})
get_filename_component(TEST_TARGET_NAME "${TEST_SOURCE_FILE}" NAME_WE)
add_executable(${TEST_TARGET_NAME} "${TEST_SOURCE_FILE}")
add_dependencies(${TEST_TARGET_NAME} C5T_CURRENT_BUILD_INFO_H_TARGET)
target_include_directories(${TEST_TARGET_NAME} PRIVATE "${CMAKE_CURRENT_BINARY_DIR}") # TODO add inc/
target_include_directories(${TEST_TARGET_NAME} PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/inc")
target_link_libraries(${TEST_TARGET_NAME} PRIVATE gtest_main "${ALL_LIBRARIES}")
add_test(NAME ${TEST_TARGET_NAME} COMMAND ${TEST_TARGET_NAME})
endforeach()

0 comments on commit eea24f7

Please sign in to comment.