cmake项目分组 (#1431)

重要项目(toolkit和mediakit)增加目录显示
This commit is contained in:
mtdxc 2022-02-17 10:33:42 +08:00 committed by GitHub
parent 304c898a3a
commit af08b58d29
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 43 additions and 0 deletions

View File

@ -80,6 +80,37 @@ option(ENABLE_WEBRTC "Enable WebRTC" true)
option(ENABLE_PLAYER "Enable Player" true)
option(ENABLE_MSVC_MT "Enable MSVC Mt/Mtd lib" true)
option(ENABLE_API_STATIC_LIB "Enable mk_api static lib" false)
option(USE_SOLUTION_FOLDERS "Enable solution dir supported" ON)
# ----------------------------------------------------------------------------
# Solution folders:
# ----------------------------------------------------------------------------
if(USE_SOLUTION_FOLDERS)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
set_property(GLOBAL PROPERTY PREDEFINED_TARGETS_FOLDER "CMakeTargets")
endif()
function(set_file_group prefix)
message(STATUS "set_file_group " ${prefix} " " ${ARGC})
foreach(FILE IN LISTS ARGN 1)
# Get the directory of the source file
get_filename_component(PARENT_DIR "${FILE}" DIRECTORY)
# Remove common directory prefix to make the group
string(REPLACE "${prefix}" "" GROUP "${PARENT_DIR}")
# Make sure we are using windows slashes
string(REPLACE "/" "\\" GROUP "${GROUP}")
# Group into "Source Files" and "Header Files"
#if ("${FILE}" MATCHES ".*\\.cpp")
# set(GROUP "Source Files${GROUP}")
#elseif("${FILE}" MATCHES ".*\\.h")
# set(GROUP "Header Files${GROUP}")
#endif()
#message(STATUS ${GROUP} " : " ${FILE})
source_group("${GROUP}" FILES "${FILE}")
endforeach()
endfunction()
if (MSVC AND ENABLE_MSVC_MT)
set(CompilerFlags
@ -264,6 +295,11 @@ else ()
add_definitions(-DWIN32_LEAN_AND_MEAN -DMP4V2_NO_STDINT_DEFS -D_CRT_SECURE_NO_WARNINGS -D_WINSOCK_DEPRECATED_NO_WARNINGS)
endif ()
if (USE_SOLUTION_FOLDERS AND (NOT GROUP_BY_EXPLORER)) # IDE
set_file_group(${ToolKit_Root} ${ToolKit_src_list})
set_file_group("${CMAKE_CURRENT_SOURCE_DIR}/src" ${MediaKit_src_list})
endif()
#
add_library(zltoolkit STATIC ${ToolKit_src_list})
add_library(zlmediakit STATIC ${MediaKit_src_list})

View File

@ -4,6 +4,9 @@ foreach(TEST_SRC ${TEST_SRC_LIST})
message(STATUS "add c api tester:${TEST_EXE_NAME}")
set(exe_name api_tester_${TEST_EXE_NAME})
add_executable(${exe_name} ${TEST_SRC})
if(USE_SOLUTION_FOLDERS)
SET_PROPERTY(TARGET ${exe_name} PROPERTY FOLDER "api_test")
endif()
if(MSVC)
set_target_properties(${exe_name} PROPERTIES COMPILE_FLAGS ${VS_FALGS} )

View File

@ -14,6 +14,10 @@ foreach (TEST_SRC ${TEST_SRC_LIST})
message(STATUS "add test:${TEST_EXE_NAME}")
add_executable(${TEST_EXE_NAME} ${TEST_SRC})
if(USE_SOLUTION_FOLDERS)
SET_PROPERTY(TARGET ${TEST_EXE_NAME} PROPERTY FOLDER "test")
endif ()
if (MSVC)
set_target_properties(${TEST_EXE_NAME} PROPERTIES COMPILE_FLAGS ${VS_FALGS})
endif ()