diff --git a/src/Common.cmake b/src/Common.cmake index ac717ff4..2e66c182 100644 --- a/src/Common.cmake +++ b/src/Common.cmake @@ -1,5 +1,7 @@ include_guard() +set(ProjectOptions_SRC_DIR "${CMAKE_CURRENT_LIST_DIR}") + # This function sets ProjectOptions_SRC_DIR using the current lists path macro(set_project_options_src_dir) get_directory_property(LISTFILE_STACK LISTFILE_STACK) diff --git a/src/CrossCompiler.cmake b/src/CrossCompiler.cmake index 204473d4..4af0b26f 100644 --- a/src/CrossCompiler.cmake +++ b/src/CrossCompiler.cmake @@ -1,5 +1,7 @@ include_guard() +set(ProjectOptions_SRC_DIR "${CMAKE_CURRENT_LIST_DIR}") + #[[.rst: ``enable_cross_compiler`` diff --git a/src/DetectCompiler.cmake b/src/DetectCompiler.cmake index bf621c23..144c327b 100644 --- a/src/DetectCompiler.cmake +++ b/src/DetectCompiler.cmake @@ -1,5 +1,7 @@ include_guard() +set(ProjectOptions_SRC_DIR "${CMAKE_CURRENT_LIST_DIR}") + # includes a separate CMakeLists.txt file to detect the CXX/C compilers before project is called # Using a separate file ensures that the current scope is not contaminated by the variable macro(detect_compiler) diff --git a/src/Doxygen.cmake b/src/Doxygen.cmake index d8eae523..ee971351 100644 --- a/src/Doxygen.cmake +++ b/src/Doxygen.cmake @@ -80,8 +80,11 @@ function(enable_doxygen DOXYGEN_THEME) # find doxygen and dot if available find_package(Doxygen OPTIONAL_COMPONENTS dot) - if (NOT Doxygen_FOUND) - message(WARNING "Doxygen not found, install doxygen and try again. Documentation will not be generated.") + if(NOT Doxygen_FOUND) + message( + WARNING + "Doxygen not found, install doxygen and try again. Documentation will not be generated." + ) return() endif() diff --git a/src/Index.cmake b/src/Index.cmake index cf89d028..3e90cdc9 100644 --- a/src/Index.cmake +++ b/src/Index.cmake @@ -10,29 +10,29 @@ if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.24.0") endif() # only useable here -set(ProjectOptions_SRC_DIR ${CMAKE_CURRENT_LIST_DIR}) +set(ProjectOptions_SRC_DIR "${CMAKE_CURRENT_LIST_DIR}") # include the files to allow calling individual functions (including the files does not run any code.) -include("${CMAKE_CURRENT_LIST_DIR}/Common.cmake") -include("${CMAKE_CURRENT_LIST_DIR}/Utilities.cmake") -include("${CMAKE_CURRENT_LIST_DIR}/Git.cmake") -include("${CMAKE_CURRENT_LIST_DIR}/SystemLink.cmake") -include("${CMAKE_CURRENT_LIST_DIR}/Cuda.cmake") -include("${CMAKE_CURRENT_LIST_DIR}/PackageProject.cmake") -include("${CMAKE_CURRENT_LIST_DIR}/Optimization.cmake") -include("${CMAKE_CURRENT_LIST_DIR}/Cache.cmake") -include("${CMAKE_CURRENT_LIST_DIR}/Linker.cmake") -include("${CMAKE_CURRENT_LIST_DIR}/CompilerWarnings.cmake") -include("${CMAKE_CURRENT_LIST_DIR}/Tests.cmake") -include("${CMAKE_CURRENT_LIST_DIR}/Sanitizers.cmake") -include("${CMAKE_CURRENT_LIST_DIR}/Doxygen.cmake") -include("${CMAKE_CURRENT_LIST_DIR}/StaticAnalyzers.cmake") -include("${CMAKE_CURRENT_LIST_DIR}/VCEnvironment.cmake") -include("${CMAKE_CURRENT_LIST_DIR}/MinGW.cmake") -include("${CMAKE_CURRENT_LIST_DIR}/DetectCompiler.cmake") -include("${CMAKE_CURRENT_LIST_DIR}/CrossCompiler.cmake") -include("${CMAKE_CURRENT_LIST_DIR}/DynamicProjectOptions.cmake") -include("${CMAKE_CURRENT_LIST_DIR}/Hardening.cmake") +include("${ProjectOptions_SRC_DIR}/Common.cmake") +include("${ProjectOptions_SRC_DIR}/Utilities.cmake") +include("${ProjectOptions_SRC_DIR}/Git.cmake") +include("${ProjectOptions_SRC_DIR}/SystemLink.cmake") +include("${ProjectOptions_SRC_DIR}/Cuda.cmake") +include("${ProjectOptions_SRC_DIR}/PackageProject.cmake") +include("${ProjectOptions_SRC_DIR}/Optimization.cmake") +include("${ProjectOptions_SRC_DIR}/Cache.cmake") +include("${ProjectOptions_SRC_DIR}/Linker.cmake") +include("${ProjectOptions_SRC_DIR}/CompilerWarnings.cmake") +include("${ProjectOptions_SRC_DIR}/Tests.cmake") +include("${ProjectOptions_SRC_DIR}/Sanitizers.cmake") +include("${ProjectOptions_SRC_DIR}/Doxygen.cmake") +include("${ProjectOptions_SRC_DIR}/StaticAnalyzers.cmake") +include("${ProjectOptions_SRC_DIR}/VCEnvironment.cmake") +include("${ProjectOptions_SRC_DIR}/MinGW.cmake") +include("${ProjectOptions_SRC_DIR}/DetectCompiler.cmake") +include("${ProjectOptions_SRC_DIR}/CrossCompiler.cmake") +include("${ProjectOptions_SRC_DIR}/DynamicProjectOptions.cmake") +include("${ProjectOptions_SRC_DIR}/Hardening.cmake") # Include msvc toolchain on windows if the generator is not visual studio. Should be called before run_vcpkg and run_conan to be effective if("${CMAKE_TOOLCHAIN_FILE}" STREQUAL "") @@ -41,8 +41,8 @@ else() message(STATUS "project_options: skipping msvc_toolchain as CMAKE_TOOLCHAIN_FILE is set") endif() -include("${CMAKE_CURRENT_LIST_DIR}/Conan.cmake") -include("${CMAKE_CURRENT_LIST_DIR}/Vcpkg.cmake") +include("${ProjectOptions_SRC_DIR}/Conan.cmake") +include("${ProjectOptions_SRC_DIR}/Vcpkg.cmake") #[[.rst: diff --git a/src/MinGW.cmake b/src/MinGW.cmake index f37b5292..69ee7aa0 100644 --- a/src/MinGW.cmake +++ b/src/MinGW.cmake @@ -1,5 +1,7 @@ include_guard() +set(ProjectOptions_SRC_DIR "${CMAKE_CURRENT_LIST_DIR}") + # detect mingw function(is_mingw value) if(USE_CROSSCOMPILER_MINGW) diff --git a/src/VCEnvironment.cmake b/src/VCEnvironment.cmake index 6773e2a9..d9a783ba 100644 --- a/src/VCEnvironment.cmake +++ b/src/VCEnvironment.cmake @@ -1,6 +1,7 @@ include_guard() -include("${CMAKE_CURRENT_LIST_DIR}/Utilities.cmake") +set(ProjectOptions_SRC_DIR "${CMAKE_CURRENT_LIST_DIR}") +include("${ProjectOptions_SRC_DIR}/Utilities.cmake") # detect if the compiler is msvc function(is_msvc value) @@ -58,8 +59,7 @@ macro(msvc_toolchain) message(STATUS "Using Windows Windows toolchain") include(FetchContent) FetchContent_Declare( - _msvc_toolchain - GIT_REPOSITORY "https://github.com/MarkSchofield/WindowsToolchain.git" + _msvc_toolchain GIT_REPOSITORY "https://github.com/MarkSchofield/WindowsToolchain.git" GIT_TAG "17c6d4ff6531ee268b9a22a8bcfbb3809e970e4e" ) FetchContent_MakeAvailable(_msvc_toolchain) diff --git a/tests/emscripten/main.cpp b/tests/emscripten/main.cpp index 7daec985..7e674a92 100644 --- a/tests/emscripten/main.cpp +++ b/tests/emscripten/main.cpp @@ -13,6 +13,6 @@ #endif int main() { - printf("hello, world!\n"); - return 0; + printf("hello, world!\n"); + return 0; } \ No newline at end of file diff --git a/tests/install/src/another_main.cpp b/tests/install/src/another_main.cpp index f14a6747..4b80c7b0 100644 --- a/tests/install/src/another_main.cpp +++ b/tests/install/src/another_main.cpp @@ -2,6 +2,6 @@ #include int main() { - some_fun2(); - return some_fun2(); + some_fun2(); + return some_fun2(); } \ No newline at end of file diff --git a/tests/minimal/main.cpp b/tests/minimal/main.cpp index 115ff095..0296dc98 100644 --- a/tests/minimal/main.cpp +++ b/tests/minimal/main.cpp @@ -1,6 +1,6 @@ #include int main() { - fmt::print("Hello World!"); - return 0; + fmt::print("Hello World!"); + return 0; } \ No newline at end of file diff --git a/tests/myproj/include/mylib/lib.hpp b/tests/myproj/include/mylib/lib.hpp index f74c7bad..8d2ed226 100644 --- a/tests/myproj/include/mylib/lib.hpp +++ b/tests/myproj/include/mylib/lib.hpp @@ -18,13 +18,13 @@ #include int some_fun() { - fmt::print("Hello from fmt{}", "!"); + fmt::print("Hello from fmt{}", "!"); - // populate an Eigen vector with the values - auto eigen_vec = Eigen::VectorXd::LinSpaced(10, 0, 1); + // populate an Eigen vector with the values + auto eigen_vec = Eigen::VectorXd::LinSpaced(10, 0, 1); - // print the vector - fmt::print("[{}]", fmt::join(eigen_vec, ", ")); + // print the vector + fmt::print("[{}]", fmt::join(eigen_vec, ", ")); - return 0; + return 0; } diff --git a/tests/myproj/libs/mythirdpartylib/include/Foo.hpp b/tests/myproj/libs/mythirdpartylib/include/Foo.hpp index 26aa7e0e..52915fce 100644 --- a/tests/myproj/libs/mythirdpartylib/include/Foo.hpp +++ b/tests/myproj/libs/mythirdpartylib/include/Foo.hpp @@ -8,18 +8,18 @@ namespace mythirdpartylib { class MYTHIRDPARTYLIB_EXPORT Foo { -public: - Foo() = default; + public: + Foo() = default; - /*implicit*/ Foo(int a) : m_a(a) {} + /*implicit*/ Foo(int a) : m_a(a) {} - int a() const { return m_a; } + int a() const { return m_a; } - void update(bool b, bool c, bool d); - void bad(std::vector &v); + void update(bool b, bool c, bool d); + void bad(std::vector &v); -private: - int m_a; + private: + int m_a; }; -} // namespace mythirdpartylib \ No newline at end of file +}// namespace mythirdpartylib \ No newline at end of file diff --git a/tests/myproj/libs/mythirdpartylib/src/Foo.cpp b/tests/myproj/libs/mythirdpartylib/src/Foo.cpp index 9e777af4..c8d279e7 100644 --- a/tests/myproj/libs/mythirdpartylib/src/Foo.cpp +++ b/tests/myproj/libs/mythirdpartylib/src/Foo.cpp @@ -3,22 +3,22 @@ namespace mythirdpartylib { void Foo::update(bool b, bool c, bool d) { - int e = b + d; - m_a = e; + int e = b + d; + m_a = e; } void Foo::bad(std::vector &v) { - std::string val = "hello"; - int index = -1; // bad, plus should use gsl::index - for (int i = 0; i < v.size(); ++i) { - if (v[i] == val) { - index = i; - break; + std::string val = "hello"; + int index = -1;// bad, plus should use gsl::index + for (int i = 0; i < v.size(); ++i) { + if (v[i] == val) { + index = i; + break; + } } - } } static Foo foo(5); static Foo bar = 42; -} // namespace mythirdpartylib \ No newline at end of file +}// namespace mythirdpartylib \ No newline at end of file diff --git a/tests/myproj/src/main/main.cpp b/tests/myproj/src/main/main.cpp index 25cc0b59..65c8ad70 100644 --- a/tests/myproj/src/main/main.cpp +++ b/tests/myproj/src/main/main.cpp @@ -16,20 +16,20 @@ #include int main() { - fmt::print("Hello from fmt{}", "!"); + fmt::print("Hello from fmt{}", "!"); - Eigen::VectorXd eigen_vec = Eigen::Vector3d(1, 2, 3); - fmt::print("[{}]", fmt::join(eigen_vec, ", ")); + Eigen::VectorXd eigen_vec = Eigen::Vector3d(1, 2, 3); + fmt::print("[{}]", fmt::join(eigen_vec, ", ")); -#if !defined(__MINGW32__) && !defined(__MSYS__) // TODO fails - Eigen::VectorXd eigen_vec2 = Eigen::VectorXd::LinSpaced(10, 0, 1); - fmt::print("[{}]", fmt::join(eigen_vec2, ", ")); +#if !defined(__MINGW32__) && !defined(__MSYS__)// TODO fails + Eigen::VectorXd eigen_vec2 = Eigen::VectorXd::LinSpaced(10, 0, 1); + fmt::print("[{}]", fmt::join(eigen_vec2, ", ")); #endif - // trigger address sanitizer - // int *p = nullptr; - // *p = 1; + // trigger address sanitizer + // int *p = nullptr; + // *p = 1; - // trigger compiler warnings, clang-tidy, and cppcheck - int a; + // trigger compiler warnings, clang-tidy, and cppcheck + int a; } diff --git a/tests/myproj/src/mylib2/lib.cpp b/tests/myproj/src/mylib2/lib.cpp index 01524a76..15cd1b02 100644 --- a/tests/myproj/src/mylib2/lib.cpp +++ b/tests/myproj/src/mylib2/lib.cpp @@ -16,15 +16,15 @@ #include int some_fun2() { - fmt::print("Hello from fmt{}", "!"); + fmt::print("Hello from fmt{}", "!"); - Eigen::VectorXd eigen_vec = Eigen::Vector3d(1, 2, 3); - fmt::print("[{}]", fmt::join(eigen_vec, ", ")); + Eigen::VectorXd eigen_vec = Eigen::Vector3d(1, 2, 3); + fmt::print("[{}]", fmt::join(eigen_vec, ", ")); -#if !defined(__MINGW32__) && !defined(__MSYS__) // TODO fails - Eigen::VectorXd eigen_vec2 = Eigen::VectorXd::LinSpaced(10, 0, 1); - fmt::print("[{}]", fmt::join(eigen_vec2, ", ")); +#if !defined(__MINGW32__) && !defined(__MSYS__)// TODO fails + Eigen::VectorXd eigen_vec2 = Eigen::VectorXd::LinSpaced(10, 0, 1); + fmt::print("[{}]", fmt::join(eigen_vec2, ", ")); #endif - return 0; + return 0; } diff --git a/tests/rpi3/main.c b/tests/rpi3/main.c index bfb7d28e..cfe6ef9c 100644 --- a/tests/rpi3/main.c +++ b/tests/rpi3/main.c @@ -5,11 +5,11 @@ char uart_getc() { return 'a'; } void uart_puts(char *s) {} void main() { - uart_init(); + uart_init(); - uart_puts("Hello World!\n"); + uart_puts("Hello World!\n"); - while (1) { - uart_send(uart_getc()); - } + while (1) { + uart_send(uart_getc()); + } } \ No newline at end of file diff --git a/tests/rpi3/main.cpp b/tests/rpi3/main.cpp index 4706104d..b94615d2 100644 --- a/tests/rpi3/main.cpp +++ b/tests/rpi3/main.cpp @@ -1,6 +1,6 @@ #include int main() { - std::cout << "Hello World!"; - return 0; + std::cout << "Hello World!"; + return 0; } \ No newline at end of file diff --git a/tests/rpi4-vcpkg/main.cpp b/tests/rpi4-vcpkg/main.cpp index 115ff095..0296dc98 100644 --- a/tests/rpi4-vcpkg/main.cpp +++ b/tests/rpi4-vcpkg/main.cpp @@ -1,6 +1,6 @@ #include int main() { - fmt::print("Hello World!"); - return 0; + fmt::print("Hello World!"); + return 0; } \ No newline at end of file diff --git a/tests/rpi4/main.cpp b/tests/rpi4/main.cpp index 4706104d..b94615d2 100644 --- a/tests/rpi4/main.cpp +++ b/tests/rpi4/main.cpp @@ -1,6 +1,6 @@ #include int main() { - std::cout << "Hello World!"; - return 0; + std::cout << "Hello World!"; + return 0; } \ No newline at end of file