Skip to content

Commit

Permalink
Merge pull request #3 from romch007/master
Browse files Browse the repository at this point in the history
Build examples with CMake
  • Loading branch information
QwEekYhyo authored Oct 2, 2024
2 parents 884f1ad + 0cf6f62 commit fd710a9
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
15 changes: 12 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ project(new_chad_neural LANGUAGES C)

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

option(BUILD_TESTS "Build tests" ON)
option(BUILD_EXAMPLES "Build examples" OFF)

include_directories(include)

if(MSVC)
Expand All @@ -12,7 +15,13 @@ else()
add_compile_options(-Wall -Wextra -Wpedantic -O3)
endif()

enable_testing()

add_subdirectory(src)
add_subdirectory(tests)

if(BUILD_TESTS)
enable_testing()
add_subdirectory(tests)
endif()

if(BUILD_EXAMPLES)
add_subdirectory(examples)
endif()
7 changes: 7 additions & 0 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
file(GLOB examples "${CMAKE_CURRENT_SOURCE_DIR}/*.c")

foreach(example_src ${examples})
get_filename_component(example_bin ${example_src} NAME_WE)
add_executable(${example_bin} ${example_src})
target_link_libraries(${example_bin} new_chad_neural)
endforeach()

0 comments on commit fd710a9

Please sign in to comment.