@@ -15,6 +15,16 @@ FetchContent_Declare(doctest
1515
1616FetchContent_MakeAvailable (doctest)
1717
18+ if ("${CMAKE_CXX_COMPILER_FRONTEND_VARIANT } " STREQUAL "MSVC" )
19+ set (FRONT_MSVC True )
20+ else ()
21+ set (FRONT_MSVC False )
22+ endif ()
23+
24+ set (CLANG_CL "$<AND :$<BOOL :${FRONT_MSVC} >,$<CXX_COMPILER_ID :Clang >>" )
25+ set (CLANG_NORMAL "$<AND :$<NOT :$<BOOL :${FRONT_MSVC} >>,$<CXX_COMPILER_ID :Clang >>" )
26+
27+
1828
1929function (configure_test name )
2030
@@ -37,29 +47,20 @@ function(configure_test name)
3747 PRIVATE
3848 $<$<CXX_COMPILER_ID :AppleClang >:-Wall -Wextra -Wpedantic
3949 -Wno -gnu -zero -variadic -macro -arguments #Clang bug - this is not an issue in C ++20
50+ -fprofile -instr -generate -fcoverage -mapping
4051 >
41- $<$<CXX_COMPILER_ID :AppleClang >:-fprofile -instr -generate -fcoverage -mapping >
52+
53+ $<${CLANG_NORMAL} :-Wall ;-Wextra ;-pedantic >
54+ $<${CLANG_CL} :/W4 ;/WX >
4255
4356 $<$<CXX_COMPILER_ID :GNU >:-Wall -Wextra -Wpedantic
4457 -Wno -unknown -pragmas #the whole point of pragmas it to be potentially unknown !
4558 >
46- $<$<CXX_COMPILER_ID :MSVC >:/utf -8
59+ $<$<CXX_COMPILER_ID :MSVC >:/utf -8 / W4 / WX
4760 /wd5285 #cannot declare a specialization for 'std ::tuple ' (in doctest )
4861 >
4962 )
5063
51- if ("${CMAKE_CXX_COMPILER_FRONTEND_VARIANT } " STREQUAL "MSVC" )
52- target_compile_options (${name}
53- PRIVATE
54- $<$<CXX_COMPILER_ID :Clang >:/W4 ;/WX >
55- )
56- else ()
57- target_compile_options (${name}
58- PRIVATE
59- $<$<CXX_COMPILER_ID :Clang >:-Wall ;-Wextra ;-pedantic >
60- )
61- endif ()
62-
6364 target_link_options (${name}
6465 PRIVATE
6566 $<$<CXX_COMPILER_ID :AppleClang >:-fprofile -instr -generate -fcoverage -mapping >
@@ -99,7 +100,7 @@ endfunction(configure_test name)
99100
100101
101102
102- add_executable (test_normal )
103+ add_executable (test_normal EXCLUDE_FROM_ALL )
103104configure_test (test_normal )
104105
105106target_compile_options (test_normal
@@ -131,25 +132,14 @@ target_compile_definitions(test_nothrow
131132target_compile_options (test_nothrow
132133 PRIVATE
133134 $<$<CXX_COMPILER_ID :AppleClang >:-fno -exceptions -fno -rtti >
135+ $<${CLANG_NORMAL} :-fno -exceptions -fno -rtti >
136+ $<${CLANG_CL} :/GR - -D_HAS_EXCEPTIONS =0>
134137 $<$<CXX_COMPILER_ID :GNU >:-fno -exceptions -fno -rtti >
135138 $<$<CXX_COMPILER_ID :MSVC >:/GR - -D_HAS_EXCEPTIONS =0>
136139)
137140
138- if ("${CMAKE_CXX_COMPILER_FRONTEND_VARIANT } " STREQUAL "MSVC" )
139- target_compile_options (test_nothrow
140- PRIVATE
141- $<$<CXX_COMPILER_ID :Clang >:/GR - -D_HAS_EXCEPTIONS =0>
142- )
143- else ()
144- target_compile_options (test_nothrow
145- PRIVATE
146- $<$<CXX_COMPILER_ID :Clang >:-fno -exceptions -fno -rtti >
147- )
148- endif ()
149-
150- add_custom_target (tests
141+ add_custom_target (tests ALL
151142 DEPENDS test_normal test_expected test_nothrow
152- ${TEST_COMMAND}
153143)
154144
155145if (${CMAKE_SYSTEM_NAME } STREQUAL Android )
@@ -164,6 +154,13 @@ if (${CMAKE_SYSTEM_NAME} STREQUAL Android)
164154 endif ()
165155endif ()
166156
157+ set (TEST_DATA_FILES
158+ ${CMAKE_CURRENT_LIST_DIR } /response.txt
159+ ${CMAKE_CURRENT_LIST_DIR } /response1.txt
160+ ${CMAKE_CURRENT_LIST_DIR } /response-recursive.txt
161+ ${CMAKE_CURRENT_LIST_DIR } /response-recursive1.txt
162+ )
163+
167164set (TEST_SRCIPT
168165"
169166cmake_path(GET EXECUTABLE FILENAME exefilename)
@@ -174,24 +171,19 @@ endmacro()
174171" )
175172
176173if (${CMAKE_SYSTEM_NAME } STREQUAL Android )
177- set (ANDROID_ARTIFACTS
178-
179- ${CMAKE_CURRENT_LIST_DIR } /response.txt
180- ${CMAKE_CURRENT_LIST_DIR } /response1.txt
181- ${CMAKE_CURRENT_LIST_DIR } /response-recursive.txt
182- ${CMAKE_CURRENT_LIST_DIR } /response-recursive1.txt
183- )
184-
185174 string (APPEND TEST_SRCIPT "
186175run(${ADB} shell mkdir -p ${ANDROID_TEST_DIR} /data)
187176run(${ADB} push \$ {EXECUTABLE} ${ANDROID_TEST_DIR} )
188177" )
189178
190- foreach (artifact ${ANDROID_ARTIFACTS } )
179+ foreach (artifact ${TEST_DATA_FILES } )
191180 string (APPEND TEST_SRCIPT "run(${ADB} push ${artifact} ${ANDROID_TEST_DIR} /data)\n " )
192181 endforeach ()
193182
194- string (APPEND TEST_SRCIPT "run(${ADB} shell \" cd ${ANDROID_TEST_DIR} && LD_LIBRARY_PATH=${ANDROID_LD_LIBRARY_PATH} ./\$ {exefilename} -ni -fc\" )\n " )
183+ string (APPEND TEST_SRCIPT "
184+ run(${ADB} shell \" cd ${ANDROID_TEST_DIR} && LD_LIBRARY_PATH=${ANDROID_LD_LIBRARY_PATH} ./\$ {exefilename} -ni -fc\" )
185+ " )
186+
195187elseif (CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang" )
196188 string (APPEND TEST_SRCIPT "
197189run(${CMAKE_COMMAND } -E env LLVM_PROFILE_FILE=${CMAKE_CURRENT_BINARY_DIR } /coverage/\$ {exefilename}.profraw \$ {EXECUTABLE} -ni -fc)
0 commit comments