Use CMAKE_BUILD_TYPE Less
This commit is contained in:
parent
a80b5fb5c2
commit
013c1db336
@ -38,14 +38,11 @@ include(cmake/options/extra-options.cmake)
|
|||||||
include(cmake/options/paths.cmake)
|
include(cmake/options/paths.cmake)
|
||||||
|
|
||||||
# Required Compile Flags
|
# Required Compile Flags
|
||||||
|
set(RELEASE_MODE_GENERATOR "\$<CONFIG:Release>")
|
||||||
string(CONCAT COMPILE_FLAGS_SETUP
|
string(CONCAT COMPILE_FLAGS_SETUP
|
||||||
# Optimizations
|
# Optimizations
|
||||||
"if(CMAKE_BUILD_TYPE MATCHES Release)\n"
|
"add_compile_options(\"\$<IF:${RELEASE_MODE_GENERATOR},-O3,-g>\")\n"
|
||||||
" add_compile_options(-O3)\n"
|
"add_link_options(\"\$<${RELEASE_MODE_GENERATOR}:-s>\")\n"
|
||||||
" add_link_options(-s)\n"
|
|
||||||
"else()\n"
|
|
||||||
" add_compile_options(-g)\n"
|
|
||||||
"endif()\n"
|
|
||||||
|
|
||||||
# PIC
|
# PIC
|
||||||
"set(CMAKE_POSITION_INDEPENDENT_CODE TRUE)\n"
|
"set(CMAKE_POSITION_INDEPENDENT_CODE TRUE)\n"
|
||||||
|
@ -32,46 +32,57 @@ force_set(MCPI_CMAKE_TOOLCHAIN_FILE "${toolchain_dir}/toolchain.cmake" FILEPATH)
|
|||||||
|
|
||||||
# Build Sysroot
|
# Build Sysroot
|
||||||
set(sysroot_dir "${CMAKE_CURRENT_BINARY_DIR}/bundled-armhf-sysroot")
|
set(sysroot_dir "${CMAKE_CURRENT_BINARY_DIR}/bundled-armhf-sysroot")
|
||||||
|
set(sysroot_dir_debug "${sysroot_dir}/debug")
|
||||||
|
set(sysroot_dir_release "${sysroot_dir}/release")
|
||||||
if("${toolchain_dir}/bin/${target}-gcc" IS_NEWER_THAN "${sysroot_dir}")
|
if("${toolchain_dir}/bin/${target}-gcc" IS_NEWER_THAN "${sysroot_dir}")
|
||||||
# Create Directory
|
# Create Directory
|
||||||
file(REMOVE_RECURSE "${sysroot_dir}")
|
file(REMOVE_RECURSE "${sysroot_dir}")
|
||||||
file(MAKE_DIRECTORY "${sysroot_dir}")
|
file(MAKE_DIRECTORY "${sysroot_dir_debug}")
|
||||||
|
file(MAKE_DIRECTORY "${sysroot_dir_release}")
|
||||||
|
|
||||||
# Copy Files From Toolchain
|
# Copy Files From Toolchain
|
||||||
file(
|
file(
|
||||||
COPY "${toolchain_dir}/${target}/libc/"
|
COPY "${toolchain_dir}/${target}/libc/"
|
||||||
DESTINATION "${sysroot_dir}"
|
DESTINATION "${sysroot_dir_debug}"
|
||||||
USE_SOURCE_PERMISSIONS
|
USE_SOURCE_PERMISSIONS
|
||||||
FILES_MATCHING
|
FILES_MATCHING
|
||||||
PATTERN "*.so*"
|
PATTERN "*.so*"
|
||||||
)
|
)
|
||||||
|
|
||||||
# Delete Unneeded Files
|
# Delete Unneeded Files
|
||||||
file(REMOVE_RECURSE "${sysroot_dir}/usr/lib/audit")
|
file(REMOVE_RECURSE "${sysroot_dir_debug}/usr/lib/audit")
|
||||||
file(REMOVE_RECURSE "${sysroot_dir}/usr/lib/gconv")
|
file(REMOVE_RECURSE "${sysroot_dir_debug}/usr/lib/gconv")
|
||||||
|
|
||||||
# Strip Files
|
# Strip Files
|
||||||
if(NOT CMAKE_BUILD_TYPE MATCHES Debug)
|
file(COPY "${sysroot_dir_debug}/." DESTINATION "${sysroot_dir_release}")
|
||||||
file(GLOB_RECURSE files LIST_DIRECTORIES FALSE "${sysroot_dir}/*")
|
file(GLOB_RECURSE files LIST_DIRECTORIES FALSE "${sysroot_dir_release}/*")
|
||||||
foreach(file IN LISTS files)
|
foreach(file IN LISTS files)
|
||||||
execute_process(
|
execute_process(
|
||||||
COMMAND "${toolchain_dir}/bin/${target}-strip" "${file}"
|
COMMAND "${toolchain_dir}/bin/${target}-strip" "${file}"
|
||||||
RESULT_VARIABLE ret
|
RESULT_VARIABLE ret
|
||||||
ERROR_QUIET
|
ERROR_QUIET
|
||||||
)
|
)
|
||||||
# Delete Invalid Files
|
# Delete Invalid Files
|
||||||
if(NOT ret EQUAL 0)
|
if(NOT ret EQUAL 0)
|
||||||
file(REMOVE "${file}")
|
file(REMOVE "${file}")
|
||||||
endif()
|
endif()
|
||||||
endforeach()
|
endforeach()
|
||||||
endif()
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Install Sysroot (Skipping Empty Directories)
|
# Install Sysroot (Skipping Empty Directories)
|
||||||
function(install_arm_sysroot)
|
function(install_arm_sysroot_config config)
|
||||||
file(GLOB_RECURSE files LIST_DIRECTORIES FALSE RELATIVE "${sysroot_dir}" "${sysroot_dir}/*")
|
set(dir "${sysroot_dir_${config}}")
|
||||||
|
file(GLOB_RECURSE files LIST_DIRECTORIES FALSE RELATIVE "${dir}" "${dir}/*")
|
||||||
foreach(file IN LISTS files)
|
foreach(file IN LISTS files)
|
||||||
cmake_path(GET file PARENT_PATH parent)
|
cmake_path(GET file PARENT_PATH parent)
|
||||||
install(PROGRAMS "${sysroot_dir}/${file}" DESTINATION "${MCPI_INSTALL_DIR}/sysroot/${parent}")
|
install(
|
||||||
|
PROGRAMS "${dir}/${file}"
|
||||||
|
DESTINATION "${MCPI_INSTALL_DIR}/sysroot/${parent}"
|
||||||
|
CONFIGURATIONS "${config}"
|
||||||
|
)
|
||||||
endforeach()
|
endforeach()
|
||||||
endfunction()
|
endfunction()
|
||||||
|
function(install_arm_sysroot)
|
||||||
|
install_arm_sysroot_config(debug)
|
||||||
|
install_arm_sysroot_config(release)
|
||||||
|
endfunction()
|
Loading…
x
Reference in New Issue
Block a user