yalantinglibs/cmake/subdir.cmake

43 lines
1.3 KiB
CMake

message(STATUS "-------------YLT PROJECT SETTING------------")
file(GLOB children src/*)
foreach(child ${children})
get_filename_component(subdir_name ${child} NAME)
string(TOUPPER ${subdir_name} subdir_name)
if (ENABLE_CPP_20)
option(BUILD_${subdir_name} "BUILD_${subdir_name}" ON)
else()
option(BUILD_${subdir_name} "BUILD_${subdir_name}" OFF)
endif()
endforeach()
if (NOT ENABLE_CPP_20)
Set(BUILD_STRUCT_PACK ON)
Set(BUILD_STRUCT_JSON ON)
Set(BUILD_STRUCT_XML ON)
Set(BUILD_STRUCT_YAML ON)
endif()
foreach(child ${children})
get_filename_component(subdir_name ${child} NAME)
string(TOUPPER ${subdir_name} subdir_name)
if((${subdir_name} STREQUAL "STRUCT_PACK" OR ${subdir_name} STREQUAL "STRUCT_PB") AND (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC"))
message(STATUS "skip ${subdir_name}")
continue()
endif()
if (BUILD_${subdir_name})
message(STATUS "BUILD_${subdir_name}: ${BUILD_${subdir_name}}")
if(BUILD_EXAMPLES AND EXISTS ${child}/examples)
add_subdirectory(${child}/examples)
endif()
if(BUILD_UNIT_TESTS AND EXISTS ${child}/tests)
add_subdirectory(${child}/tests)
endif()
if(BUILD_BENCHMARK AND EXISTS ${child}/benchmark)
add_subdirectory(${child}/benchmark)
endif()
endif()
endforeach()
message(STATUS "--------------------------------------------")