File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -11,15 +11,13 @@ project(
1111
1212include (cmake/StandardSettings.cmake )
1313
14- set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR} )
14+ set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR} )
1515
1616set (CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR} /bin" )
1717set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR} /bin/int" )
1818set (CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR} /bin/lib" )
1919
20- include_directories (${CMAKE_SOURCE_DIR} /src )
21-
22- add_executable (${PROJECT_NAME} src/main.cpp )
20+ add_executable (${PROJECT_NAME} src/main.cpp )
2321add_subdirectory (src )
2422target_link_libraries (
2523 ${PROJECT_NAME}
Original file line number Diff line number Diff line change 22# Default settings
33#
44set (CMAKE_CXX_VISIBILITY_PRESET hidden)
5- set (CMAKE_POSITION_INDEPENDENT_CODE ON )
5+ # set(CMAKE_POSITION_INDEPENDENT_CODE ON)
66set (CMAKE_EXPORT_COMPILE_COMMANDS 1)
Original file line number Diff line number Diff line change 1- # Add any new directory that you add in ProjectFolder/src here
2- file (GLOB_RECURSE sources utility/*.cpp )
3- add_library (${PROJECT_NAME} _LIB ${sources} )
1+ set (sources_list
2+ # Add here any file you want to add manually which is not in a
3+ # src/directory.
4+ )
5+
6+ # Getting all the .cpp files in any src/directory.
7+ file (GLOB directories */ )
8+ foreach (dir ${directories} )
9+ if (IS_DIRECTORY ${dir} )
10+ string (FIND ${dir} "/" last_slash_pos REVERSE)
11+ math (EXPR string_start "${last_slash_pos} +1" )
12+ string (SUBSTRING ${dir} ${string_start} -1 dir_stripped)
13+ file (GLOB_RECURSE sources ${dir_stripped} /*.cpp )
14+ list (APPEND sources_list ${sources} )
15+ endif ()
16+ endforeach ()
17+
18+ add_library (${PROJECT_NAME} _LIB ${sources_list} )
19+
20+ target_include_directories (
21+ ${PROJECT_NAME} _LIB
22+ PUBLIC
23+ ${CMAKE_SOURCE_DIR} /src
24+ )
425
526target_compile_definitions (
627 ${PROJECT_NAME} _LIB
@@ -33,7 +54,7 @@ target_link_libraries(
3354 # Add libraries to link to the binary here
3455)
3556
36- set_target_properties (
37- ${PROJECT_NAME} _LIB
38- PROPERTIES ENABLE_EXPORTS ON
39- )
57+ # set_target_properties(
58+ # ${PROJECT_NAME}_LIB
59+ # # Add any target properties here
60+ # )
Original file line number Diff line number Diff line change @@ -37,7 +37,9 @@ To run tests in a Docker container:<br>
3737
3838<h2 >Notes:</h2 >
3939
40- - When creating a new folder in ProjectFolder/src<br >
41- also add its name in ProjectFolder/src/CMakeLists.txt
40+ - To add new files create a new folder in ProjectFolder/src,<br >
41+ no CMake files need to be modified.<br >
42+ You need to re-run "build_cmake".
4243- To add a new test just add a new test_ *** .cpp file<br >
43- in ProjectFolder/test.
44+ in ProjectFolder/test.<br >
45+ You need to re-run "build_cmake".
You can’t perform that action at this time.
0 commit comments