Skip to content

Commit

Permalink
Added BasicRendererLib target
Browse files Browse the repository at this point in the history
  • Loading branch information
giuliom committed Jul 24, 2024
1 parent 8c95e3a commit d0a5836
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 11 deletions.
32 changes: 24 additions & 8 deletions BasicRenderer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,34 @@ include(FetchContent)
# Avoid warnings by using new policy
cmake_policy(SET CMP0135 NEW)


# ------ BasicCppLibrary ----- #

# BasicCppLibrary
FetchContent_Declare(
BasicCppLibrary
GIT_REPOSITORY https://github.com/giuliom/BasicCppLibrary.git
GIT_TAG main
)
FetchContent_MakeAvailable(BasicCppLibrary)

# ------ BasicRenderer ----- #

# ------ BasicRenderer Library ----- #

set (LIBRARY_NAME BasicRendererLib)
file(GLOB SOURCES "${PROJECT_SOURCE_DIR}/source/*.cpp" "${PROJECT_SOURCE_DIR}/include/*.h")
list(REMOVE_ITEM SOURCES "${PROJECT_SOURCE_DIR}/source/main.cpp")

add_executable(${PROJECT_NAME} ${SOURCES})
target_include_directories(${PROJECT_NAME} PUBLIC ${PROJECT_SOURCE_DIR}/include)
add_library(${LIBRARY_NAME} STATIC ${SOURCES})
set_target_properties(${LIBRARY_NAME} PROPERTIES LINKER_LANGUAGE CXX)
target_include_directories(${LIBRARY_NAME} PUBLIC ${PROJECT_SOURCE_DIR}/include)

target_link_libraries(${LIBRARY_NAME} PUBLIC BasicCppLibrary)
add_dependencies(${LIBRARY_NAME} BasicCppLibrary)

# Set the library version (optional)
set_target_properties(${LIBRARY_NAME} PROPERTIES VERSION 1.0 SOVERSION 1)
install(TARGETS ${LIBRARY_NAME} DESTINATION lib)

target_link_libraries(${PROJECT_NAME} PUBLIC BasicCppLibrary)
add_dependencies(${PROJECT_NAME} BasicCppLibrary)

# ------ Google Test ----- #

Expand All @@ -42,14 +51,21 @@ FetchContent_MakeAvailable(googletest)
enable_testing()

file (GLOB TESTS "test/*.h" "test/*.cpp")
list(REMOVE_ITEM SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/source/main.cpp")
add_executable(BasicRendererTest ${TESTS} ${SOURCES})
target_include_directories(BasicRendererTest PUBLIC ${PROJECT_SOURCE_DIR}/include)

target_link_libraries(
BasicRendererTest
${LIBRARY_NAME}
GTest::gtest_main
)

include(GoogleTest)
gtest_discover_tests(BasicRendererTest)
gtest_discover_tests(BasicRendererTest)

# ------ BasicRenderer Executable ----- #

add_executable(${PROJECT_NAME} ${SOURCES} "${PROJECT_SOURCE_DIR}/source/main.cpp")

target_include_directories(${PROJECT_NAME} PUBLIC ${PROJECT_SOURCE_DIR}/include)
target_link_libraries(${PROJECT_NAME} PUBLIC ${LIBRARY_NAME})
2 changes: 1 addition & 1 deletion BasicRenderer/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

echo "Building BasicRenderer"
cmake -S . -B build
cmake --build build
cmake --build build --config release --target BasicRenderer
4 changes: 2 additions & 2 deletions BasicRenderer/run_tests.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

cmake -S . -B build
cmake --build build
cmake --build build --config release
cd build
ctest
ctest -C release

0 comments on commit d0a5836

Please sign in to comment.