├── .gitignore ├── .gitmodules ├── Adder ├── CMakeLists.txt ├── adder.cpp └── adder.h ├── CMakeLists.txt ├── CMakeSettings.json ├── CTestConfig.cmake ├── License.txt ├── OLASConfig.h.in ├── readme.md └── tests ├── CMakeLists.txt └── math ├── CMakeLists.txt └── tester.cpp /.gitignore: -------------------------------------------------------------------------------- 1 | # Prerequisites 2 | *.d 3 | 4 | # Compiled Object files 5 | *.slo 6 | *.lo 7 | *.o 8 | *.obj 9 | 10 | # Precompiled Headers 11 | *.gch 12 | *.pch 13 | 14 | # Compiled Dynamic libraries 15 | *.so 16 | *.dylib 17 | *.dll 18 | 19 | # Fortran module files 20 | *.mod 21 | *.smod 22 | 23 | # Compiled Static libraries 24 | *.lai 25 | *.la 26 | *.a 27 | *.lib 28 | 29 | # Executables 30 | *.exe 31 | *.out 32 | *.app 33 | 34 | 35 | CMakeLists.txt.user 36 | CMakeCache.txt 37 | CMakeFiles 38 | CMakeScripts 39 | Testing 40 | Makefile 41 | cmake_install.cmake 42 | install_manifest.txt 43 | compile_commands.json 44 | CTestTestfile.cmake 45 | _deps 46 | 47 | 48 | [Oo][Uu][Tt]/ 49 | [Bb][Uu][Ii][Ll][Dd]/ 50 | .vscode/settings.json 51 | .vs/ 52 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codetechandtutorials/OurLordAndSavior/81e3b952cc666cff8fa0a5cb7baf71ddca50cc69/.gitmodules -------------------------------------------------------------------------------- /Adder/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.15) 2 | 3 | add_library(adder adder.cpp adder.h) 4 | 5 | install(TARGETS adder DESTINATION lib) 6 | install(FILES adder.h DESTINATION include) 7 | -------------------------------------------------------------------------------- /Adder/adder.cpp: -------------------------------------------------------------------------------- 1 | #include "adder.h" 2 | 3 | double add(double a, double b) 4 | { 5 | return (a + b); 6 | } 7 | 8 | float add(float a, float b) 9 | { 10 | return (a + b); 11 | } -------------------------------------------------------------------------------- /Adder/adder.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | double add(double a, double b); 4 | 5 | float add(float a, float b); 6 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.15) 2 | 3 | project(OLAS VERSION 1.1) 4 | 5 | #find_package(GLEW REQUIRED) 6 | # 7 | ## get glfw from github 8 | #find_package(Git QUIET) 9 | #if(GIT_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git") 10 | ## Update submodules as needed 11 | # option(GIT_SUBMODULE "Check submodules during build" ON) 12 | # if(GIT_SUBMODULE) 13 | # message(STATUS "Submodule update") 14 | # execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive 15 | # WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} 16 | # RESULT_VARIABLE GIT_SUBMOD_RESULT) 17 | # if(NOT GIT_SUBMOD_RESULT EQUAL "0") 18 | # message(FATAL_ERROR "git submodule update --init failed with ${GIT_SUBMOD_RESULT}, please checkout submodules") 19 | # endif() 20 | # endif() 21 | #endif() 22 | # 23 | ## CHECK ALL THE SUBMODULES 24 | #if(NOT EXISTS "${PROJECT_SOURCE_DIR}/external/glfw/CMakeLists.txt") 25 | # message(FATAL_ERROR "The glfw submodules was not downloaded! GIT_SUBMODULE was turned off or failed. Please update submodules and try again.") 26 | #endif() 27 | # 28 | #add_subdirectory(external/glfw) 29 | 30 | 31 | # adder use logic 32 | option(USE_ADDER "A simple library for adding 2 floats." ON) 33 | option(TEST_ADDER "Test library for adding 2 floats." ON) 34 | #option(TEST_GRAPHICS "Test launching opengl with glfw window." ON) 35 | 36 | if(USE_ADDER) 37 | add_subdirectory(Adder) 38 | list(APPEND EXTRA_LIB_DIRS "Adder") 39 | list(APPEND EXTRA_INCLUDE_DIRS "Adder") 40 | list(APPEND EXTRA_LINKS adder) 41 | endif() 42 | 43 | configure_file(OLASConfig.h.in OLASConfig.h) 44 | 45 | if(TEST_ADDER) 46 | enable_testing() 47 | add_subdirectory(tests) 48 | include(CTest) 49 | endif() 50 | 51 | install(FILES "${PROJECT_BINARY_DIR}/OLASConfig.h" DESTINATION include) 52 | 53 | include(InstallRequiredSystemLibraries) 54 | set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/License.txt") 55 | set(CPACK_PACKAGE_VERSION_MAJOR "${Tutorial_VERSION_MAJOR}") 56 | set(CPACK_PACKAGE_VERSION_MINOR "${Tutorial_VERSION_MINOR}") 57 | include(CPack) 58 | 59 | -------------------------------------------------------------------------------- /CMakeSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "configurations": [ 3 | { 4 | "name": "x64-Debug", 5 | "generator": "Ninja", 6 | "configurationType": "Debug", 7 | "inheritEnvironments": [ "msvc_x64_x64" ], 8 | "buildRoot": "${projectDir}\\out\\build\\${name}", 9 | "installRoot": "${projectDir}\\out\\install\\${name}", 10 | "cmakeCommandArgs": "", 11 | "buildCommandArgs": "", 12 | "ctestCommandArgs": "" 13 | }, 14 | { 15 | "name": "x64-Release", 16 | "generator": "Ninja", 17 | "configurationType": "MinSizeRel", 18 | "buildRoot": "${projectDir}\\out\\build\\${name}", 19 | "installRoot": "${projectDir}\\out\\install\\${name}", 20 | "cmakeCommandArgs": "", 21 | "buildCommandArgs": "", 22 | "ctestCommandArgs": "", 23 | "inheritEnvironments": [ "msvc_x64_x64" ], 24 | "variables": [] 25 | } 26 | ] 27 | } -------------------------------------------------------------------------------- /CTestConfig.cmake: -------------------------------------------------------------------------------- 1 | ## This file should be placed in the root directory of your project. 2 | ## Then modify the CMakeLists.txt file in the root directory of your 3 | ## project to incorporate the testing dashboard. 4 | ## 5 | ## # The following are required to submit to the CDash dashboard: 6 | ## ENABLE_TESTING() 7 | ## INCLUDE(CTest) 8 | 9 | set(CTEST_PROJECT_NAME "OLAS") 10 | set(CTEST_NIGHTLY_START_TIME "01:00:00 UTC") 11 | 12 | set(CTEST_DROP_METHOD "https") 13 | set(CTEST_DROP_SITE "my.cdash.org") 14 | set(CTEST_DROP_LOCATION "/submit.php?project=OLAS") 15 | set(CTEST_DROP_SITE_CDASH TRUE) 16 | -------------------------------------------------------------------------------- /License.txt: -------------------------------------------------------------------------------- 1 | 2 | Copyright (c) 2020 Code, Tech, and Tutorials YouTube Channel | https://www.youtube.com/channel/UC4EJN2OSNdl-mSxGjitRvyA | codetechtuts@gmail.com 3 | 4 | This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. 5 | 6 | Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 7 | 8 | 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 9 | 10 | 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 11 | 12 | 3. This notice may not be removed or altered from any source distribution. 13 | -------------------------------------------------------------------------------- /OLASConfig.h.in: -------------------------------------------------------------------------------- 1 | #define OLAS_VERSION_MAJOR @OLAS_VERSION_MAJOR@ 2 | #define OLAS_VERSION_MINOR @OLAS_VERSION_MINOR@ 3 | 4 | #cmakedefine USE_ADDER 5 | #cmakedefine TEST_ADDER 6 | #cmakedefine TEST_GRAPHICS 7 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # OurLordAndSavior 2 | 3 | The build system generator that we should probably all use, CMake. 4 | 5 | This repo is generated for the set of [CMake Tutorials](https://www.youtube.com/watch?v=nlKcXPUJGwA&list=PLalVdRk2RC6o5GHu618ARWh0VO0bFlif4) 6 | 7 | -------------------------------------------------------------------------------- /tests/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.15) 2 | 3 | add_subdirectory(math) 4 | -------------------------------------------------------------------------------- /tests/math/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.15) 2 | 3 | add_executable(math_test tester.cpp) 4 | 5 | target_include_directories(math_test 6 | PUBLIC ${EXTRA_INCLUDE_DIRS} 7 | ) 8 | 9 | target_link_directories(math_test 10 | PUBLIC ${EXTRA_LIB_DIRS} 11 | ) 12 | 13 | target_link_libraries(math_test PUBLIC ${EXTRA_LINKS}) 14 | 15 | add_test(NAME "Math.Adder.Test1" COMMAND "math_test" 1 6 WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) 16 | add_test(NAME "Math.Adder.Test2" COMMAND "math_test" 2 8 WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) 17 | add_test(NAME "Math.Adder.Test3" COMMAND "math_test" 3 2 WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) 18 | add_test(NAME "Math.Adder.Test4" COMMAND "math_test" 4 92 WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) 19 | 20 | include(InstallRequiredSystemLibraries) 21 | install(TARGETS math_test DESTINATION bin) 22 | -------------------------------------------------------------------------------- /tests/math/tester.cpp: -------------------------------------------------------------------------------- 1 | #include "../../Adder/adder.h" 2 | #include 3 | int main(int argc, char** argv) 4 | { 5 | if (argc < 3) return -1; // invalid parameter count 6 | 7 | double cpp_add_value = atof(argv[1]) + atof(argv[2]); 8 | double adder_add_value = add(atof(argv[1]), atof(argv[2])); 9 | 10 | int return_value = (cpp_add_value == adder_add_value) ? EXIT_SUCCESS : EXIT_FAILURE; 11 | 12 | return return_value; 13 | 14 | } 15 | --------------------------------------------------------------------------------