Skip to content

Commit

Permalink
use unity builds
Browse files Browse the repository at this point in the history
  • Loading branch information
Tyler-Lentz committed Apr 18, 2024
1 parent 2c0b92a commit 6bf4fc7
Show file tree
Hide file tree
Showing 10 changed files with 61 additions and 14 deletions.
14 changes: 9 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ FATAL: In-source builds are not allowed.
endif()

# enable build caching
find_program(CCACHE ccache)
if(CCACHE)
set(CMAKE_C_COMPILER_LAUNCHER ${CCACHE})
set(CMAKE_CXX_COMPILER_LAUNCHER ${CCACHE})
endif(CCACHE)
# find_program(CCACHE ccache)
# if(CCACHE)
# set(CMAKE_C_COMPILER_LAUNCHER ${CCACHE})
# set(CMAKE_CXX_COMPILER_LAUNCHER ${CCACHE})
# endif(CCACHE)

set(CMAKE_CXX_COMPILER g++)
set(CMAKE_CXX_STANDARD 20)
Expand Down Expand Up @@ -100,6 +100,10 @@ add_definitions( -DMAGICKCORE_HDRI_ENABLE=0 )
find_package(ImageMagick COMPONENTS Magick++ REQUIRED)
# =============================

function(set_unity_for_target target_name)
set_target_properties(${target_name} PROPERTIES UNITY_BUILD ON UNITY_BUILD_MODE BATCH UNITY_BUILD_BATCH_SIZE 16 UNITY_BUILD_UNIQUE_ID "MY_UNITY_ID")
endfunction()

# =============================
# obcpp library & executable

Expand Down
2 changes: 1 addition & 1 deletion protos
Submodule protos updated 1 files
+2 −2 obc.proto
4 changes: 4 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
add_library(obcpp_protos STATIC ${PROJECT_SOURCE_DIR}/build/gen_protos/protos/obc.pb.cc)

add_subdirectory(camera)
add_subdirectory(core)
add_subdirectory(cv)
Expand All @@ -8,6 +10,7 @@ add_subdirectory(utilities)

add_library(obcpp_lib INTERFACE)
target_link_libraries(obcpp_lib INTERFACE
obcpp_protos
obcpp_camera
obcpp_core
obcpp_cv
Expand All @@ -20,6 +23,7 @@ target_link_libraries(obcpp_lib INTERFACE
# for use in unit tests
add_library(obcpp_lib_mock INTERFACE)
target_link_libraries(obcpp_lib_mock INTERFACE
obcpp_protos
obcpp_camera
obcpp_core
obcpp_cv
Expand Down
12 changes: 11 additions & 1 deletion src/camera/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,20 @@ set(FILES
mock.cpp
)

add_library(${LIB_NAME} STATIC ${PROJECT_SOURCE_DIR}/build/gen_protos/protos/obc.pb.cc
SET(LIB_DEPS
obcpp_protos
)

add_library(${LIB_NAME} STATIC
${FILES}
)

target_link_libraries(${LIB_NAME} PRIVATE
${LIB_DEPS}
)

set_unity_for_target(${LIB_NAME})

target_add_protobuf(${LIB_NAME})
target_add_torch(${LIB_NAME})
# target_add_arena(${LIB_NAME}) # Tyler: currently broken, so we had to comment this out
Expand Down
5 changes: 4 additions & 1 deletion src/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ set(FILES
)

set(LIB_DEPS
obcpp_protos
obcpp_camera
obcpp_cv
obcpp_network
Expand All @@ -15,14 +16,16 @@ set(LIB_DEPS
obcpp_utilities
)

add_library(${LIB_NAME} STATIC ${PROJECT_SOURCE_DIR}/build/gen_protos/protos/obc.pb.cc
add_library(${LIB_NAME} STATIC
${FILES}
)

target_link_libraries(${LIB_NAME} PRIVATE
${LIB_DEPS}
)

set_unity_for_target(${LIB_NAME})

target_add_protobuf(${LIB_NAME})
target_add_torch(${LIB_NAME})
# target_add_arena(${LIB_NAME}) # Tyler: currently broken, so we had to comment this out
Expand Down
11 changes: 9 additions & 2 deletions src/cv/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,21 @@ set(FILES
utilities.cpp
)

add_library(${LIB_NAME} STATIC ${PROJECT_SOURCE_DIR}/build/gen_protos/protos/obc.pb.cc
set(LIB_DEPS
obcpp_protos
obcpp_utilities
)

add_library(${LIB_NAME} STATIC
${FILES}
)

target_link_libraries(${LIB_NAME} PRIVATE
obcpp_utilities
${LIB_DEPS}
)

set_unity_for_target(${LIB_NAME})

target_add_protobuf(${LIB_NAME})
target_add_torch(${LIB_NAME})
# target_add_arena(${LIB_NAME}) # Tyler: currently broken, so we had to comment this out
Expand Down
5 changes: 4 additions & 1 deletion src/network/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,23 @@ set(MOCK_FILES
)

set(LIB_DEPS
obcpp_protos
obcpp_utilities
obcpp_ticks
obcpp_core
obcpp_pathing
)

add_library(${LIB_NAME} STATIC ${PROJECT_SOURCE_DIR}/build/gen_protos/protos/obc.pb.cc
add_library(${LIB_NAME} STATIC
${FILES}
)

target_link_libraries(${LIB_NAME} PRIVATE
${LIB_DEPS}
)

set_unity_for_target(${LIB_NAME})

target_add_protobuf(${LIB_NAME})
target_add_torch(${LIB_NAME})
# target_add_arena(${LIB_NAME}) # Tyler: currently broken, so we had to comment this out
Expand Down
5 changes: 4 additions & 1 deletion src/pathing/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,20 @@ set(FILES
)

set (LIB_DEPS
obcpp_protos
obcpp_core
obcpp_network
obcpp_utilities
)

add_library(${LIB_NAME} STATIC ${PROJECT_SOURCE_DIR}/build/gen_protos/protos/obc.pb.cc
add_library(${LIB_NAME} STATIC
${FILES}
)

target_link_libraries(${LIB_NAME} PRIVATE ${LIB_DEPS})

set_unity_for_target(${LIB_NAME})

target_add_protobuf(${LIB_NAME})
target_add_torch(${LIB_NAME})
# target_add_arena(${LIB_NAME}) # Tyler: currently broken, so we had to comment this out
Expand Down
5 changes: 4 additions & 1 deletion src/ticks/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,23 @@ set(FILES
)

set(LIB_DEPS
obcpp_protos
obcpp_pathing
obcpp_utilities
obcpp_core
obcpp_network
)

add_library(${LIB_NAME} STATIC ${PROJECT_SOURCE_DIR}/build/gen_protos/protos/obc.pb.cc
add_library(${LIB_NAME} STATIC
${FILES}
)

target_link_libraries(${LIB_NAME} PRIVATE
${LIB_DEPS}
)

set_unity_for_target(${LIB_NAME})

target_add_protobuf(${LIB_NAME})
target_add_torch(${LIB_NAME})
# target_add_arena(${LIB_NAME}) # Tyler: currently broken, so we had to comment this out
Expand Down
12 changes: 11 additions & 1 deletion src/utilities/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,20 @@ SET(FILES
rng.cpp
)

add_library(${LIB_NAME} STATIC ${PROJECT_SOURCE_DIR}/build/gen_protos/protos/obc.pb.cc
SET(LIB_DEPS
obcpp_protos
)

add_library(${LIB_NAME} STATIC
${FILES}
)

target_link_libraries(${LIB_NAME} PRIVATE
${LIB_DEPS}
)

set_unity_for_target(${LIB_NAME})

target_add_protobuf(${LIB_NAME})
target_add_torch(${LIB_NAME})
# target_add_arena(${LIB_NAME}) # Tyler: currently broken, so we had to comment this out
Expand Down

0 comments on commit 6bf4fc7

Please sign in to comment.