Skip to content

Commit

Permalink
Feat: Adding unix build
Browse files Browse the repository at this point in the history
  • Loading branch information
Grabt234 committed Dec 16, 2023
1 parent 94c3221 commit ea0562d
Showing 1 changed file with 68 additions and 9 deletions.
77 changes: 68 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,74 @@
cmake_minimum_required(VERSION 3.18)
project(BaseModuleProject CXX)

# Set directory vars
set(SOURCE_DIR "source")
set(INCLUDE_DIR "include")
set(SOURCE_TESTS_DIR "source_tests")
set(INCLUDE_TESTS_DIR "include_tests")

idf_component_register(
SRCS
${SOURCE_DIR}/BaseModule.cpp
${SOURCE_DIR}/RouterModule.cpp
INCLUDE_DIRS
${INCLUDE_DIR}
REQUIRES
Chunk_Types
)
if(DEFINED ENV{IDF_PATH}) # this is normally only set when running in an esp idf terminal
message(STATUS "Building for ESP32")

idf_component_register(
SRCS
${SOURCE_DIR}/BaseModule.cpp
${SOURCE_DIR}/RouterModule.cpp
INCLUDE_DIRS
${INCLUDE_DIR}
REQUIRES
Chunk_Types
)

else()
message(STATUS "Building for Unix")

# Set C++ standard
set(CMAKE_CXX_STANDARD 20)

# Main executable
file(GLOB SOURCES "${SOURCE_DIR}/*.cpp")
add_library(BaseModuleLib
${SOURCES}
)

# Test executable
add_executable(BaseModuleTest
${SOURCE_TESTS_DIR}/BaseModuleTest.cpp
)

add_subdirectory(components/Chunk_Types)
add_subdirectory(components/plog)

# Include directories for main code and tests
target_include_directories(BaseModuleLib
PRIVATE ${INCLUDE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/components/Chunk_Types/include
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/components/plog/include
)

target_include_directories(BaseModuleTest
PRIVATE ${INCLUDE_DIR}
PRIVATE ${INCLUDE_TESTS_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/components/doctest/doctest
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/components/Chunk_Types/include
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/components/plog/include
)

# Adding threads
target_link_libraries(BaseModuleLib PRIVATE pthread)
target_link_libraries(BaseModuleLib PRIVATE ${THREADS_LIBRARIES})

# Link with required libraries for the main executable
target_link_libraries(BaseModuleLib PRIVATE doctest::doctest)

# Link with required libraries for the test executable
target_link_libraries(BaseModuleTest PRIVATE BaseModuleLib doctest::doctest)

# Enable testing
enable_testing()

# Add tests to CTest
add_test(NAME BaseModuleTest COMMAND BaseModuleTest)

endif()

0 comments on commit ea0562d

Please sign in to comment.