CMakeLists: Handle older compilers; target trimming
1. The 'compile_cpp' for c 17 doesn't work on MSVC 2019 or older gccs
2. These tests and the like should only be included if building clap
directly
@@ -2,8 +2,6 @@ cmake_minimum_required(VERSION 3.17)
enable_testing()
project(CLAP C CXX)
-add_custom_target(clap-tests)
-
# If you use clap as a submodule of your plugin you need some interface projects
# to allow you to link. clap-core gives you the include directory and clap-plugin-core
# gives you the core + plugin-glue.
@@ -12,6 +10,17 @@ target_include_directories(clap-core INTERFACE include)
install(DIRECTORY include DESTINATION "." OPTIONAL EXCLUDE_FROM_ALL)
+get_directory_property(parent_dir PARENT_DIRECTORY)
+if ("${parent_dir}" STREQUAL "")
+ set(CLAP_IS_TOPLEVEL 1)
+else ()
+ set(CLAP_IS_TOPLEVEL 0)
+endif ()
+
+if (${CLAP_IS_TOPLEVEL})
+ message(STATUS "Including clap tests, compile tests, and versions")
+ add_custom_target(clap-tests)
+
add_executable(clap-compile-c EXCLUDE_FROM_ALL src/main.c)
macro(clap_compile_cpp SUFFIX EXT STDC STDCPP)
@@ -35,7 +44,8 @@ endmacro()
clap_compile_cpp(c11 c 11 11)
clap_compile_cpp(cpp11 cc 11 11)
clap_compile_cpp(cpp14 cc 11 14)
-clap_compile_cpp(c17 c 17 17)
+ # This configuration isn't supported by MSVC or older gccs so leave it off for now
+ # clap_compile_cpp(c17 c 17 17)
clap_compile_cpp(cpp17 cc 17 17)
clap_compile_cpp(cpp20 cc 17 20)
@@ -62,3 +72,4 @@ elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows")
set_target_properties(clap-plugin-template PROPERTIES SUFFIX ".clap" PREFIX "")
endif()
+endif()
