-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initialize a cmake project with google test
Finish initialization. We add google test, .clang-tidy and .clang-format. And we finish CMakeLists.txt in root directory and test directory.
- Loading branch information
1 parent
be91320
commit adf4694
Showing
8 changed files
with
137 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
--- | ||
Language: Cpp | ||
BasedOnStyle: Google | ||
AlignConsecutiveAssignments: true | ||
AlignConsecutiveDeclarations: false | ||
AlignConsecutiveMacros: true | ||
AllowAllParametersOfDeclarationOnNextLine: false | ||
AllowShortFunctionsOnASingleLine: All | ||
AllowShortBlocksOnASingleLine: true | ||
AllowShortCaseLabelsOnASingleLine: true | ||
AllowShortIfStatementsOnASingleLine: true | ||
AllowShortLoopsOnASingleLine: true | ||
AlwaysBreakAfterReturnType: None | ||
AlwaysBreakTemplateDeclarations: true | ||
BreakBeforeTernaryOperators: false | ||
BinPackArguments: false | ||
BinPackParameters: false | ||
ColumnLimit: 100 | ||
DerivePointerAlignment: false | ||
IndentWidth: 4 | ||
MaxEmptyLinesToKeep: 1 | ||
PointerAlignment: Right | ||
SortIncludes: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
Checks: > | ||
-*, | ||
cppcoreguidelines-no-malloc, modernize-deprecated-headers, | ||
modernize-loop-convert, modernize-make-shared, modernize-pass-by-value, modernize-make-unique, | ||
modernize-raw-string-literal, modernize-redundant-void-arg, modernize-replace-auto-ptr, | ||
modernize-replace-random-shuffle, modernize-return-braced-init-list, modernize-shrink-to-fit, | ||
modernize-unary-static-assert, modernize-use-bool-literals, modernize-use-default-member-init, | ||
modernize-use-emplace, modernize-use-equals-default, modernize-use-equals-delete, | ||
modernize-use-noexcept, modernize-use-nullptr, modernize-use-override, | ||
modernize-use-transparent-functors, modernize-use-using, | ||
performance-faster-string-find, performance-for-range-copy, | ||
performance-implicit-conversion-in-loop, performance-inefficient-algorithm, | ||
performance-inefficient-string-concatenation, performance-trivially-destructible, | ||
performance-inefficient-vector-operation, performance-move-const-arg, | ||
performance-move-constructor-init, performance-noexcept-move-constructor, | ||
performance-no-automatic-move, performance-unnecessary-copy-initialization, | ||
performance-type-promotion-in-math-fn, performance-unnecessary-value-param | ||
WarningsAsErrors: > | ||
cppcoreguidelines-no-malloc, modernize-deprecated-headers, | ||
modernize-loop-convert, modernize-make-shared, modernize-pass-by-value, modernize-make-unique, | ||
modernize-raw-string-literal, modernize-redundant-void-arg, modernize-replace-auto-ptr, | ||
modernize-replace-random-shuffle, modernize-return-braced-init-list, modernize-shrink-to-fit, | ||
modernize-unary-static-assert, modernize-use-bool-literals, modernize-use-default-member-init, | ||
modernize-use-emplace, modernize-use-equals-default, modernize-use-equals-delete, | ||
modernize-use-noexcept, modernize-use-nullptr, modernize-use-override, | ||
modernize-use-transparent-functors, modernize-use-using, | ||
performance-faster-string-find, performance-for-range-copy, | ||
performance-implicit-conversion-in-loop, performance-inefficient-algorithm, | ||
performance-inefficient-string-concatenation, performance-trivially-destructible, | ||
performance-inefficient-vector-operation, performance-move-const-arg, | ||
performance-move-constructor-init, performance-noexcept-move-constructor, | ||
performance-no-automatic-move, performance-unnecessary-copy-initialization, | ||
performance-type-promotion-in-math-fn, performance-unnecessary-value-param | ||
HeaderFilterRegex: '^(src\/.*|include\/.*)$' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,3 +30,13 @@ | |
*.exe | ||
*.out | ||
*.app | ||
|
||
# build | ||
*build*/ | ||
|
||
# vscode | ||
*.vscode*/ | ||
|
||
# cache | ||
*.cache*/ | ||
*__pycache__*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
cmake_minimum_required(VERSION 3.14) | ||
|
||
project(mca) | ||
|
||
set(CMAKE_CXX_STANDARD 17) | ||
set(CMAKE_C_STANDARD_REQUIRED on) | ||
set(CMAKE_EXPORT_COMPILE_COMMANDS on) | ||
set(CMAKE_CXX_EXTENSIONS off) | ||
|
||
if (WIN32) | ||
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) | ||
endif() | ||
|
||
option(MCA_BUILD_SHARE_LIB "Build shared libraries rather than static libraries" on) | ||
option(MCA_BUILD_TEST "Whether or not to build unit test" on) | ||
|
||
aux_source_directory(src MCA_SOURCE) | ||
set(LIBRARY_OUTPUT_PATH lib) | ||
if (MCA_BUILD_SHARE_LIB) | ||
add_library(mca SHARED ${MCA_SOURCE}) | ||
else() | ||
add_library(mca STATIC ${MCA_SOURCE}) | ||
endif() | ||
|
||
find_program(CLANG_TIDY_EXE NAMES clang-tidy) | ||
if (NOT CLANG_TIDY_EXE STREQUAL "CLANG_TIDY_EXE-NOTFOUND") | ||
set_target_properties(mca PROPERTIES CXX_CLANG_TIDY "${CLANG_TIDY_EXE}") | ||
endif() | ||
|
||
if (MCA_BUILD_TEST) | ||
add_subdirectory(test) | ||
endif() |
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
cmake_minimum_required(VERSION 3.14) | ||
|
||
set(CMAKE_CXX_STANDARD 17) | ||
set(CMAKE_C_STANDARD_REQUIRED on) | ||
set(CMAKE_EXPORT_COMPILE_COMMANDS on) | ||
set(CMAKE_CXX_EXTENSIONS off) | ||
|
||
if (WIN32) | ||
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) | ||
endif() | ||
|
||
|
||
include(FetchContent) | ||
FetchContent_Declare( | ||
googletest | ||
URL https://github.com/google/googletest/archive/03597a01ee50ed33e9dfd640b249b4be3799d395.zip) | ||
|
||
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) | ||
FetchContent_MakeAvailable(googletest) | ||
# enable testing in cmake | ||
enable_testing() | ||
include(GoogleTest) | ||
|
||
aux_source_directory(src UNIT_TEST_SOURCE) | ||
add_executable(${PROJECT_NAME}_unit_test ${UNIT_TEST_SOURCE}) | ||
target_link_libraries( | ||
${PROJECT_NAME}_unit_test | ||
GTest::gtest_main | ||
mca) | ||
gtest_discover_tests(${PROJECT_NAME}_unit_test) | ||
|
||
find_program(CLANG_TIDY_EXE NAMES clang-tidy) | ||
if (NOT CLANG_TIDY_EXE STREQUAL "CLANG_TIDY_EXE-NOTFOUND") | ||
set_target_properties(${PROJECT_NAME}_unit_test PROPERTIES CXX_CLANG_TIDY "${CLANG_TIDY_EXE}") | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
#include <gtest/gtest.h> |