mirror of
https://git.mirrors.martin98.com/https://github.com/google/draco
synced 2025-09-12 23:23:15 +08:00
Fixed cmake build
This commit is contained in:
parent
4b2788bb56
commit
02272a65c7
@ -26,7 +26,7 @@ macro (add_c_flag_if_supported c_flag)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${c_flag}" CACHE STRING "")
|
||||
else ()
|
||||
set(DRACO_FAILED_C_FLAGS "${DRACO_FAILED_C_FLAGS} ${c_flag}" CACHE STRING
|
||||
"")
|
||||
"" FORCE)
|
||||
endif ()
|
||||
endif ()
|
||||
endmacro ()
|
||||
@ -48,7 +48,7 @@ macro (add_cxx_flag_if_supported cxx_flag)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${cxx_flag}" CACHE STRING "")
|
||||
else()
|
||||
set(DRACO_FAILED_CXX_FLAGS "${DRACO_FAILED_CXX_FLAGS} ${cxx_flag}" CACHE
|
||||
STRING "")
|
||||
STRING "" FORCE)
|
||||
endif ()
|
||||
endif ()
|
||||
endmacro ()
|
||||
@ -75,7 +75,7 @@ macro (require_c_flag c_flag update_c_flags)
|
||||
"${PROJECT_NAME} requires support for C flag: ${c_flag}.")
|
||||
endif ()
|
||||
if (${update_c_flags})
|
||||
set(CMAKE_C_FLAGS "${c_flag} ${CMAKE_C_FLAGS}")
|
||||
set(CMAKE_C_FLAGS "${c_flag} ${CMAKE_C_FLAGS}" CACHE STRING "" FORCE)
|
||||
endif ()
|
||||
endif ()
|
||||
endmacro ()
|
||||
@ -95,7 +95,8 @@ macro (require_cxx_flag cxx_flag update_cxx_flags)
|
||||
"${PROJECT_NAME} requires support for CXX flag: ${cxx_flag}.")
|
||||
endif ()
|
||||
if (${update_cxx_flags})
|
||||
set(CMAKE_CXX_FLAGS "${cxx_flag} ${CMAKE_CXX_FLAGS}")
|
||||
set(CMAKE_CXX_FLAGS "${cxx_flag} ${CMAKE_CXX_FLAGS}" CACHE STRING ""
|
||||
FORCE)
|
||||
endif ()
|
||||
endif ()
|
||||
endmacro ()
|
||||
@ -131,35 +132,6 @@ macro (require_compiler_flag_nomsvc flag update_cmake_flags)
|
||||
require_cxx_flag_nomsvc(${flag} ${update_cmake_flags})
|
||||
endmacro ()
|
||||
|
||||
# Adds $preproc_def to C compiler command line (as -D$preproc_def) if not
|
||||
# already present.
|
||||
macro (add_c_preproc_definition preproc_def)
|
||||
unset(PREPROC_DEF_FOUND CACHE)
|
||||
string(FIND "${CMAKE_C_FLAGS}" "${preproc_def}" PREPROC_DEF_FOUND)
|
||||
|
||||
if (${PREPROC_DEF_FOUND} EQUAL -1)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D${preproc_def}")
|
||||
endif ()
|
||||
endmacro ()
|
||||
|
||||
# Adds $preproc_def to CXX compiler command line (as -D$preproc_def) if not
|
||||
# already present.
|
||||
macro (add_cxx_preproc_definition preproc_def)
|
||||
unset(PREPROC_DEF_FOUND CACHE)
|
||||
string(FIND "${CMAKE_CXX_FLAGS}" "${preproc_def}" PREPROC_DEF_FOUND)
|
||||
|
||||
if (${PREPROC_DEF_FOUND} EQUAL -1)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D${preproc_def}")
|
||||
endif ()
|
||||
endmacro ()
|
||||
|
||||
# Adds $preproc_def to C and CXX compiler command line (as -D$preproc_def) if
|
||||
# not already present.
|
||||
macro (add_preproc_definition preproc_def)
|
||||
add_c_preproc_definition(${preproc_def})
|
||||
add_cxx_preproc_definition(${preproc_def})
|
||||
endmacro ()
|
||||
|
||||
# Adds $flag to assembler command line.
|
||||
macro (append_as_flag flag)
|
||||
unset(AS_FLAG_FOUND CACHE)
|
||||
|
57
cmake/draco_features.cmake
Normal file
57
cmake/draco_features.cmake
Normal file
@ -0,0 +1,57 @@
|
||||
if (NOT DRACO_CMAKE_DRACO_FEATURES_CMAKE_)
|
||||
set(DRACO_CMAKE_DRACO_FEATURES_CMAKE_ 1)
|
||||
|
||||
set(draco_features_file_name "${draco_build_dir}/draco/draco_features.h")
|
||||
set(draco_features_list)
|
||||
|
||||
# Macro that handles tracking of Draco preprocessor symbols for the purpose of
|
||||
# producing draco_features.h.
|
||||
#
|
||||
# draco_enable_feature(FEATURE <feature_name> [TARGETS <target_name>])
|
||||
# FEATURE is required. It should be a Draco preprocessor symbol.
|
||||
# TARGETS is optional. It can be one or more draco targets.
|
||||
#
|
||||
# When the TARGETS argument is not present the preproc symbol is added to
|
||||
# draco_features.h. When it is draco_features.h is unchanged, and
|
||||
# target_compile_options() is called for each target specified.
|
||||
macro (draco_enable_feature)
|
||||
set(def_flags)
|
||||
set(def_single_arg_opts FEATURE)
|
||||
set(def_multi_arg_opts TARGETS)
|
||||
cmake_parse_arguments(DEF "${def_flags}" "${def_single_arg_opts}"
|
||||
"${def_multi_arg_opts}" ${ARGN})
|
||||
if ("${DEF_FEATURE}" STREQUAL "")
|
||||
message(FATAL_ERROR "Empty FEATURE passed to draco_enable_feature().")
|
||||
endif ()
|
||||
|
||||
# Do nothing/return early if $DEF_FEATURE is already in the list.
|
||||
list(FIND draco_features_list ${DEF_FEATURE} df_index)
|
||||
if (NOT df_index EQUAL -1)
|
||||
return ()
|
||||
endif ()
|
||||
|
||||
list(LENGTH DEF_TARGETS df_targets_list_length)
|
||||
if (${df_targets_list_length} EQUAL 0)
|
||||
list(APPEND draco_features_list ${DEF_FEATURE})
|
||||
else ()
|
||||
foreach (target ${DEF_TARGETS})
|
||||
target_compile_definitions(${target} PRIVATE ${DEF_FEATURE})
|
||||
endforeach ()
|
||||
endif ()
|
||||
endmacro ()
|
||||
|
||||
# Function for generating draco_features.h.
|
||||
function (draco_generate_features_h)
|
||||
file(WRITE "${draco_features_file_name}"
|
||||
"// GENERATED FILE -- DO NOT EDIT\n\n"
|
||||
"#ifndef DRACO_FEATURES_H_\n"
|
||||
"#define DRACO_FEATURES_H_\n\n")
|
||||
|
||||
foreach (feature ${draco_features_list})
|
||||
file(APPEND "${draco_features_file_name}" "#define ${feature}\n")
|
||||
endforeach ()
|
||||
|
||||
file(APPEND "${draco_features_file_name}" "\n#endif // DRACO_FEATURES_H_")
|
||||
endfunction ()
|
||||
|
||||
endif () # DRACO_CMAKE_DRACO_FEATURES_CMAKE_
|
Loading…
x
Reference in New Issue
Block a user