Skip to content

Commit e017b10

Browse files
author
Omegastick
committed
Only add CppCheck target if this is the main project
1 parent fc4945b commit e017b10

File tree

1 file changed

+26
-24
lines changed

1 file changed

+26
-24
lines changed

CMakeLists.txt

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -9,31 +9,33 @@ project(CppRl
99
set(CMAKE_CXX_STANDARD 17)
1010

1111
# Cppcheck
12-
list(APPEND CPPCHECK_ARGS
13-
--enable=warning
14-
--std=c++14
15-
--force
16-
--verbose
17-
--quiet
18-
--inline-suppr
19-
--error-exitcode=1
20-
--language=c++
21-
--config-exclude=${CMAKE_CURRENT_LIST_DIR}/src/third_party
22-
--config-exclude=${CMAKE_CURRENT_LIST_DIR}/lib
23-
-i${CMAKE_CURRENT_LIST_DIR}/example/lib
24-
--suppressions-list=${CMAKE_CURRENT_LIST_DIR}/CppCheckSuppressions.txt
25-
-I ${CMAKE_CURRENT_LIST_DIR}/src
26-
-I ${CMAKE_CURRENT_LIST_DIR}/include
27-
-I ${CMAKE_CURRENT_LIST_DIR}/example
28-
${CMAKE_CURRENT_LIST_DIR}/src
29-
${CMAKE_CURRENT_LIST_DIR}/example
30-
)
12+
if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
13+
list(APPEND CPPCHECK_ARGS
14+
--enable=warning
15+
--std=c++14
16+
--force
17+
--verbose
18+
--quiet
19+
--inline-suppr
20+
--error-exitcode=1
21+
--language=c++
22+
--config-exclude=${CMAKE_CURRENT_LIST_DIR}/src/third_party
23+
--config-exclude=${CMAKE_CURRENT_LIST_DIR}/lib
24+
-i${CMAKE_CURRENT_LIST_DIR}/example/lib
25+
--suppressions-list=${CMAKE_CURRENT_LIST_DIR}/CppCheckSuppressions.txt
26+
-I ${CMAKE_CURRENT_LIST_DIR}/src
27+
-I ${CMAKE_CURRENT_LIST_DIR}/include
28+
-I ${CMAKE_CURRENT_LIST_DIR}/example
29+
${CMAKE_CURRENT_LIST_DIR}/src
30+
${CMAKE_CURRENT_LIST_DIR}/example
31+
)
3132

32-
add_custom_target(
33-
check
34-
COMMAND cppcheck ${CPPCHECK_ARGS}
35-
COMMENT "Running Cppcheck"
36-
)
33+
add_custom_target(
34+
check
35+
COMMAND cppcheck ${CPPCHECK_ARGS}
36+
COMMENT "Running Cppcheck"
37+
)
38+
endif(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
3739

3840
# Dependencies
3941
## PyTorch

0 commit comments

Comments
 (0)