Skip to content

Commit 923635f

Browse files
feat: add testing and include all subdirs except graphics
1 parent 72d94a3 commit 923635f

File tree

24 files changed

+157
-127
lines changed

24 files changed

+157
-127
lines changed

CMakeLists.txt

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
1212

1313
include(CTest) # for testing algorithms
1414

15+
option(ENABLE_TESTING "flag to test the repo" OFF)
16+
if(ENABLE_TESTING)
17+
message(STATUS "Testing enabled")
18+
enable_testing()
19+
endif()
20+
1521
# Additional warnings and errors
1622
if(MSVC)
1723
add_compile_definitions(_CRT_SECURE_NO_WARNINGS)
@@ -23,13 +29,13 @@ endif()
2329
option(USE_OPENMP "flag to use OpenMP for multithreading" ON)
2430
if(USE_OPENMP)
2531
find_package(OpenMP 3.0 COMPONENTS CXX)
26-
if (OpenMP_CXX_FOUND)
32+
if(OpenMP_CXX_FOUND)
2733
message(STATUS "Building with OpenMP Multithreading.")
2834
else()
2935
message(STATUS "No OpenMP found, no multithreading.")
3036
endif()
3137
endif()
32-
38+
3339
add_subdirectory(backtracking)
3440
add_subdirectory(bit_manipulation)
3541
add_subdirectory(ciphers)
@@ -59,19 +65,19 @@ cmake_policy(SET CMP0054 NEW)
5965
cmake_policy(SET CMP0057 NEW)
6066

6167
find_package(Doxygen OPTIONAL_COMPONENTS dot dia)
62-
if(DOXYGEN_FOUND)
68+
if(DOXYGEN_FOUND)
6369
if(MSVC)
6470
set(DOXYGEN_CPP_CLI_SUPPORT YES)
6571
endif()
6672

6773
if(Doxygen_dot_FOUND)
6874
set(DOXYGEN_HAVE_DOT YES)
6975
endif()
70-
76+
7177
if(OPENMP_FOUND)
7278
set(DOXYGEN_PREDEFINED "_OPENMP=1")
7379
endif()
74-
80+
7581
if(GLUT_FOUND)
7682
set(DOXYGEN_PREDEFINED ${DOXYGEN_PREDEFINED} "GLUT_FOUND=1")
7783
endif()

backtracking/CMakeLists.txt

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
# If necessary, use the RELATIVE flag, otherwise each source file may be listed
22
# with full pathname. RELATIVE may makes it easier to extract an executable name
33
# automatically.
4-
file( GLOB APP_SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp )
4+
file(GLOB APP_SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp)
55
# file( GLOB APP_SOURCES ${CMAKE_SOURCE_DIR}/*.c )
66
# AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR} APP_SOURCES)
7-
foreach( testsourcefile ${APP_SOURCES} )
7+
foreach(testsourcefile ${APP_SOURCES})
88
# I used a simple string replace, to cut off .cpp.
9-
string( REPLACE ".cpp" "" testname ${testsourcefile} )
10-
add_executable( ${testname} ${testsourcefile} )
9+
string(REPLACE ".cpp" "" testname ${testsourcefile})
10+
add_executable(${testname} ${testsourcefile})
1111

1212
set_target_properties(${testname} PROPERTIES LINKER_LANGUAGE CXX)
1313
if(OpenMP_CXX_FOUND)
1414
target_link_libraries(${testname} OpenMP::OpenMP_CXX)
1515
endif()
16+
add_test(${testname} ${testname})
1617
install(TARGETS ${testname} DESTINATION "bin/backtracking")
1718

18-
endforeach( testsourcefile ${APP_SOURCES} )
19+
endforeach(testsourcefile ${APP_SOURCES})

bit_manipulation/CMakeLists.txt

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
# If necessary, use the RELATIVE flag, otherwise each source file may be listed
22
# with full pathname. RELATIVE may makes it easier to extract an executable name
33
# automatically.
4-
file( GLOB APP_SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp )
4+
file(GLOB APP_SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp)
55
# file( GLOB APP_SOURCES ${CMAKE_SOURCE_DIR}/*.c )
66
# AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR} APP_SOURCES)
7-
foreach( testsourcefile ${APP_SOURCES} )
7+
foreach(testsourcefile ${APP_SOURCES})
88
# I used a simple string replace, to cut off .cpp.
9-
string( REPLACE ".cpp" "" testname ${testsourcefile} )
10-
add_executable( ${testname} ${testsourcefile} )
9+
string(REPLACE ".cpp" "" testname ${testsourcefile})
10+
add_executable(${testname} ${testsourcefile})
1111

1212
set_target_properties(${testname} PROPERTIES LINKER_LANGUAGE CXX)
1313
if(OpenMP_CXX_FOUND)
1414
target_link_libraries(${testname} OpenMP::OpenMP_CXX)
1515
endif()
16+
add_test(${testname} ${testname})
1617
install(TARGETS ${testname} DESTINATION "bin/bit_manipulation")
1718

18-
endforeach( testsourcefile ${APP_SOURCES} )
19+
endforeach(testsourcefile ${APP_SOURCES})

ciphers/CMakeLists.txt

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
# If necessary, use the RELATIVE flag, otherwise each source file may be listed
22
# with full pathname. RELATIVE may makes it easier to extract an executable name
33
# automatically.
4-
file( GLOB APP_SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp )
4+
file(GLOB APP_SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp)
55
# file( GLOB APP_SOURCES ${CMAKE_SOURCE_DIR}/*.c )
66
# AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR} APP_SOURCES)
7-
foreach( testsourcefile ${APP_SOURCES} )
7+
foreach(testsourcefile ${APP_SOURCES})
88
# I used a simple string replace, to cut off .cpp.
9-
string( REPLACE ".cpp" "" testname ${testsourcefile} )
10-
add_executable( ${testname} ${testsourcefile} )
9+
string(REPLACE ".cpp" "" testname ${testsourcefile})
10+
add_executable(${testname} ${testsourcefile})
1111

1212
set_target_properties(${testname} PROPERTIES LINKER_LANGUAGE CXX)
1313
if(OpenMP_CXX_FOUND)
1414
target_link_libraries(${testname} OpenMP::OpenMP_CXX)
1515
endif()
16+
add_test(${testname} ${testname})
1617
install(TARGETS ${testname} DESTINATION "bin/ciphers")
1718

18-
endforeach( testsourcefile ${APP_SOURCES} )
19+
endforeach(testsourcefile ${APP_SOURCES})

cpu_scheduling_algorithms/CMakeLists.txt

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,16 @@
22
# with full pathname. The RELATIVE flag makes it easier to extract an executable's name
33
# automatically.
44

5-
file( GLOB APP_SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp )
6-
foreach( testsourcefile ${APP_SOURCES} )
7-
string( REPLACE ".cpp" "" testname ${testsourcefile} ) # File type. Example: `.cpp`
8-
add_executable( ${testname} ${testsourcefile} )
5+
file(GLOB APP_SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp)
6+
foreach(testsourcefile ${APP_SOURCES})
7+
string(REPLACE ".cpp" "" testname ${testsourcefile}) # File type. Example: `.cpp`
8+
add_executable(${testname} ${testsourcefile})
99

1010
set_target_properties(${testname} PROPERTIES LINKER_LANGUAGE CXX)
1111
if(OpenMP_CXX_FOUND)
1212
target_link_libraries(${testname} OpenMP::OpenMP_CXX)
1313
endif()
14+
add_test(${testname} ${testname})
1415
install(TARGETS ${testname} DESTINATION "bin/cpu_scheduling_algorithms") # Folder name. Do NOT include `<>`
1516

16-
endforeach( testsourcefile ${APP_SOURCES} )
17+
endforeach(testsourcefile ${APP_SOURCES})

data_structures/CMakeLists.txt

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
11
# If necessary, use the RELATIVE flag, otherwise each source file may be listed
22
# with full pathname. RELATIVE may makes it easier to extract an executable name
33
# automatically.
4-
file( GLOB APP_SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp )
4+
file(GLOB APP_SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp)
55
# file( GLOB APP_SOURCES ${CMAKE_SOURCE_DIR}/*.c )
66
# AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR} APP_SOURCES)
7-
foreach( testsourcefile ${APP_SOURCES} )
7+
foreach(testsourcefile ${APP_SOURCES})
88
# I used a simple string replace, to cut off .cpp.
9-
string( REPLACE ".cpp" "" testname ${testsourcefile} )
10-
add_executable( ${testname} ${testsourcefile} )
9+
string(REPLACE ".cpp" "" testname ${testsourcefile})
10+
add_executable(${testname} ${testsourcefile})
1111

1212
set_target_properties(${testname} PROPERTIES LINKER_LANGUAGE CXX)
1313
if(OpenMP_CXX_FOUND)
1414
target_link_libraries(${testname} OpenMP::OpenMP_CXX)
1515
endif()
16+
add_test(${testname} ${testname})
1617
install(TARGETS ${testname} DESTINATION "bin/data_structures")
1718

18-
endforeach( testsourcefile ${APP_SOURCES} )
19+
endforeach(testsourcefile ${APP_SOURCES})
1920

2021
add_subdirectory(cll)

divide_and_conquer/CMakeLists.txt

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
# If necessary, use the RELATIVE flag, otherwise each source file may be listed
22
# with full pathname. RELATIVE may makes it easier to extract an executable name
33
# automatically.
4-
file( GLOB APP_SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp )
4+
file(GLOB APP_SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp)
55
# file( GLOB APP_SOURCES ${CMAKE_SOURCE_DIR}/*.c )
66
# AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR} APP_SOURCES)
7-
foreach( testsourcefile ${APP_SOURCES} )
7+
foreach(testsourcefile ${APP_SOURCES})
88
# I used a simple string replace, to cut off .cpp.
9-
string( REPLACE ".cpp" "" testname ${testsourcefile} )
10-
add_executable( ${testname} ${testsourcefile} )
9+
string(REPLACE ".cpp" "" testname ${testsourcefile})
10+
add_executable(${testname} ${testsourcefile})
1111

1212
set_target_properties(${testname} PROPERTIES LINKER_LANGUAGE CXX)
1313
if(OpenMP_CXX_FOUND)
1414
target_link_libraries(${testname} OpenMP::OpenMP_CXX)
1515
endif()
16+
add_test(${testname} ${testname})
1617
install(TARGETS ${testname} DESTINATION "bin/divide_and_conquer")
1718

18-
endforeach( testsourcefile ${APP_SOURCES} )
19+
endforeach(testsourcefile ${APP_SOURCES})

dynamic_programming/CMakeLists.txt

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
# If necessary, use the RELATIVE flag, otherwise each source file may be listed
22
# with full pathname. RELATIVE may makes it easier to extract an executable name
33
# automatically.
4-
file( GLOB APP_SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp )
4+
file(GLOB APP_SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp)
55
# file( GLOB APP_SOURCES ${CMAKE_SOURCE_DIR}/*.c )
66
# AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR} APP_SOURCES)
7-
foreach( testsourcefile ${APP_SOURCES} )
7+
foreach(testsourcefile ${APP_SOURCES})
88
# I used a simple string replace, to cut off .cpp.
9-
string( REPLACE ".cpp" "" testname ${testsourcefile} )
10-
add_executable( ${testname} ${testsourcefile} )
9+
string(REPLACE ".cpp" "" testname ${testsourcefile})
10+
add_executable(${testname} ${testsourcefile})
1111

1212
set_target_properties(${testname} PROPERTIES LINKER_LANGUAGE CXX)
1313
if(OpenMP_CXX_FOUND)
1414
target_link_libraries(${testname} OpenMP::OpenMP_CXX)
1515
endif()
16+
add_test(${testname} ${testname})
1617
install(TARGETS ${testname} DESTINATION "bin/dynamic_programming")
1718

18-
endforeach( testsourcefile ${APP_SOURCES} )
19+
endforeach(testsourcefile ${APP_SOURCES})

geometry/CMakeLists.txt

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
# If necessary, use the RELATIVE flag, otherwise each source file may be listed
22
# with full pathname. RELATIVE may makes it easier to extract an executable name
33
# automatically.
4-
file( GLOB APP_SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp )
4+
file(GLOB APP_SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp)
55
# file( GLOB APP_SOURCES ${CMAKE_SOURCE_DIR}/*.c )
66
# AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR} APP_SOURCES)
7-
foreach( testsourcefile ${APP_SOURCES} )
7+
foreach(testsourcefile ${APP_SOURCES})
88
# I used a simple string replace, to cut off .cpp.
9-
string( REPLACE ".cpp" "" testname ${testsourcefile} )
10-
add_executable( ${testname} ${testsourcefile} )
9+
string(REPLACE ".cpp" "" testname ${testsourcefile})
10+
add_executable(${testname} ${testsourcefile})
1111

1212
set_target_properties(${testname} PROPERTIES LINKER_LANGUAGE CXX)
1313
if(OpenMP_CXX_FOUND)
1414
target_link_libraries(${testname} OpenMP::OpenMP_CXX)
1515
endif()
16+
add_test(${testname} ${testname})
1617
install(TARGETS ${testname} DESTINATION "bin/geometry")
1718

18-
endforeach( testsourcefile ${APP_SOURCES} )
19+
endforeach(testsourcefile ${APP_SOURCES})

graph/CMakeLists.txt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,18 @@
44
file(GLOB APP_SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp)
55
#file(GLOB APP_SOURCES ${CMAKE_SOURCE_DIR}/*.c )
66
# AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR} APP_SOURCES)
7-
foreach( testsourcefile ${APP_SOURCES} )
7+
foreach(testsourcefile ${APP_SOURCES})
88
# I used a simple string replace, to cut off .cpp.
9-
string( REPLACE ".cpp" "" testname ${testsourcefile} )
10-
add_executable( ${testname} ${testsourcefile} )
9+
string(REPLACE ".cpp" "" testname ${testsourcefile})
10+
add_executable(${testname} ${testsourcefile})
1111

1212
set_target_properties(${testname} PROPERTIES
1313
LINKER_LANGUAGE CXX
1414
)
1515
if(OpenMP_CXX_FOUND)
1616
target_link_libraries(${testname} OpenMP::OpenMP_CXX)
1717
endif()
18+
add_test(${testname} ${testname})
1819
install(TARGETS ${testname} DESTINATION "bin/graph")
1920

20-
endforeach( testsourcefile ${APP_SOURCES} )
21+
endforeach(testsourcefile ${APP_SOURCES})

0 commit comments

Comments
 (0)