summaryrefslogtreecommitdiff
path: root/libs/cargs/cmake
diff options
context:
space:
mode:
authorsanine <sanine.not@pm.me>2022-08-24 00:02:17 -0500
committersanine <sanine.not@pm.me>2022-08-24 00:02:17 -0500
commit2cb3c3df4099297b0a0554bb482e2de04fe86b5c (patch)
tree7796b4064c16460d9d603707b5256027649aa8b6 /libs/cargs/cmake
parent709e1b6e1ce86f8da4fc136747fcefbc6c6057bd (diff)
add command-line arguments
Diffstat (limited to 'libs/cargs/cmake')
-rw-r--r--libs/cargs/cmake/CargsConfig.cmake.in5
-rw-r--r--libs/cargs/cmake/CreateTestList.cmake11
-rwxr-xr-xlibs/cargs/cmake/EnableWarnings.cmake19
3 files changed, 35 insertions, 0 deletions
diff --git a/libs/cargs/cmake/CargsConfig.cmake.in b/libs/cargs/cmake/CargsConfig.cmake.in
new file mode 100644
index 0000000..bb11824
--- /dev/null
+++ b/libs/cargs/cmake/CargsConfig.cmake.in
@@ -0,0 +1,5 @@
+@PACKAGE_INIT@
+
+include("${CMAKE_CURRENT_LIST_DIR}/CargsTargets.cmake")
+
+check_required_components(cargs)
diff --git a/libs/cargs/cmake/CreateTestList.cmake b/libs/cargs/cmake/CreateTestList.cmake
new file mode 100644
index 0000000..2dd46b3
--- /dev/null
+++ b/libs/cargs/cmake/CreateTestList.cmake
@@ -0,0 +1,11 @@
+function(create_test_list list_name file)
+ set("TEST_LIST_FILE_${list_name}" ${file} PARENT_SCOPE)
+ file(WRITE ${file} "#define UNIT_TESTS(XX) \\\n")
+ file(APPEND ${file} ${TEST_LIST_CONTENT_${list_name}})
+ file(APPEND ${file} "\n")
+endfunction()
+
+function(create_test list_name unit_name test_name)
+ set(TEST_LIST_CONTENT_${list_name} "${TEST_LIST_CONTENT_${list_name}} XX(${unit_name},${test_name}) \\\n" PARENT_SCOPE)
+ add_test(NAME "${unit_name}_${test_name}" COMMAND ${TEST_TARGET} ${unit_name} ${test_name})
+endfunction() \ No newline at end of file
diff --git a/libs/cargs/cmake/EnableWarnings.cmake b/libs/cargs/cmake/EnableWarnings.cmake
new file mode 100755
index 0000000..bfce52f
--- /dev/null
+++ b/libs/cargs/cmake/EnableWarnings.cmake
@@ -0,0 +1,19 @@
+# enable warnings
+function(enable_warnings target)
+ if(MSVC)
+ target_compile_definitions(${target} PRIVATE _CRT_SECURE_NO_WARNINGS)
+ target_compile_options(${target} PRIVATE /W4)
+ target_compile_options(${target} PRIVATE /WX)
+ elseif("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang")
+ target_compile_options(${target} PRIVATE -Werror)
+ target_compile_options(${target} PRIVATE -Wall)
+ target_compile_options(${target} PRIVATE -Wextra)
+ target_compile_options(${target} PRIVATE -Wpedantic)
+ target_compile_options(${target} PRIVATE -Wno-gnu-zero-variadic-macro-arguments)
+ elseif("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU")
+ target_compile_options(${target} PRIVATE -Wall)
+ target_compile_options(${target} PRIVATE -Werror)
+ target_compile_options(${target} PRIVATE -Wextra)
+ target_compile_options(${target} PRIVATE -Wpedantic)
+ endif()
+endfunction() \ No newline at end of file