Skip to content

Commit

Permalink
[win32] add vs2022 build helper scripts + ASAN (#99)
Browse files Browse the repository at this point in the history
* [win32] add vs2022 build helper scripts

* [win32] simplify ASAN detection on MSVC

* [cmake] add ASAN_OPTIONS for bin2c not to be crashed by ASAN
  • Loading branch information
hkrn authored Jan 21, 2022
1 parent 8cda979 commit 05fcff6
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 13 deletions.
12 changes: 4 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ if(MSVC)
elseif(${MSVC_VERSION} GREATER_EQUAL 1800)
set(NANOEM_TARGET_COMPILER "vs2013" CACHE STRING "Target architecture to build nanoem")
endif()
set_property(CACHE NANOEM_TARGET_COMPILER PROPERTY STRINGS "clang;vs2019;vs2017;vs2015;vs2013")
set_property(CACHE NANOEM_TARGET_COMPILER PROPERTY STRINGS "clang;vs2022;vs2019;vs2017;vs2015;vs2013")
else()
if(${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
set(NANOEM_TARGET_COMPILER "clang" CACHE STRING "Target architecture to build nanoem")
Expand Down Expand Up @@ -166,13 +166,9 @@ function(nanoem_cmake_bootstrap _project_name_prefix _build_type)
set(${_project_name_prefix} NANOEM PARENT_SCOPE)
if(NANOEM_ENABLE_ASAN)
if(MSVC)
find_library(ASAN_LIBRARY_DLL_CRT clang_rt.asan_dll_thunk-${NANOEM_TARGET_ARCHITECTURE})
find_library(ASAN_LIBRARY_EXE_CXX_CRT clang_rt.asan_cxx-${NANOEM_TARGET_ARCHITECTURE})
set(CMAKE_C_FLAGS_ASAN "-fsanitize=address" CACHE STRING "Flags used by the C compiler during ASan builds." FORCE)
set(CMAKE_CXX_FLAGS_ASAN "-fsanitize=address" CACHE STRING "Flags used by the C++ compiler during ASan builds." FORCE)
set(CMAKE_EXE_LINKER_FLAGS_ASAN "-incremental:no /wholearchive:\"${ASAN_LIBRARY_EXE_CXX_CRT}\"" CACHE STRING "")
set(CMAKE_SHARED_LINKER_FLAGS_ASAN "-incremental:no /wholearchive:\"${ASAN_LIBRARY_DLL_CRT}\"" CACHE STRING "")
mark_as_advanced(ASAN_LIBRARY_DLL_CRT ASAN_LIBRARY_EXE_CXX_CRT CMAKE_C_FLAGS_ASAN CMAKE_CXX_FLAGS_ASAN CMAKE_EXE_LINKER_FLAGS_ASAN CMAKE_STATIC_LINKER_FLAGS_ASAN CMAKE_SHARED_LINKER_FLAGS_ASAN)
set(CMAKE_C_FLAGS_ASAN "/fsanitize=address" CACHE STRING "Flags used by the C compiler during ASan builds." FORCE)
set(CMAKE_CXX_FLAGS_ASAN "/fsanitize=address" CACHE STRING "Flags used by the C++ compiler during ASan builds." FORCE)
mark_as_advanced(CMAKE_C_FLAGS_ASAN CMAKE_CXX_FLAGS_ASAN)
else()
find_package(ASan)
endif()
Expand Down
6 changes: 4 additions & 2 deletions emapp/resources/fonts/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ function(nanoem_emapp_build_emarb_font)
# font_awesome (v4.7)
add_custom_command(OUTPUT ${output_path_prefix}/font_awesome.h
COMMAND ${CMAKE_COMMAND} ARGS -E copy ${CMAKE_CURRENT_SOURCE_DIR}/font_awesome.ttf ${intermediate_path_prefix}/font_awesome.ttf
COMMAND $<TARGET_FILE:emarb_bin2c> --input=${intermediate_path_prefix}/font_awesome.ttf --symbol=font_awesome_ttf --compressed=true
COMMAND ${CMAKE_COMMAND} -E env ASAN_OPTIONS="detect_leaks=0"
$<TARGET_FILE:emarb_bin2c> --input=${intermediate_path_prefix}/font_awesome.ttf --symbol=font_awesome_ttf --compressed=true
> ${output_path_prefix}/font_awesome.h
MAIN_DEPENDENCY ${CMAKE_CURRENT_SOURCE_DIR}/font_awesome.ttf)
# genei_gothic_p_semi_bold (v1.1)
add_custom_command(OUTPUT ${output_path_prefix}/genei_gothic_p_semi_bold.h
COMMAND ${CMAKE_COMMAND} ARGS -E copy ${CMAKE_CURRENT_SOURCE_DIR}/genei_gothic_p_semi_bold.otf ${intermediate_path_prefix}/genei_gothic_p_semi_bold.otf
COMMAND $<TARGET_FILE:emarb_bin2c> --input=${intermediate_path_prefix}/genei_gothic_p_semi_bold.otf --symbol=genei_gothic_p_semi_bold_otf --compressed=true
COMMAND ${CMAKE_COMMAND} -E env ASAN_OPTIONS="detect_leaks=0"
$<TARGET_FILE:emarb_bin2c> --input=${intermediate_path_prefix}/genei_gothic_p_semi_bold.otf --symbol=genei_gothic_p_semi_bold_otf --compressed=true
> ${output_path_prefix}/genei_gothic_p_semi_bold.h
MAIN_DEPENDENCY ${CMAKE_CURRENT_SOURCE_DIR}/genei_gothic_p_semi_bold.otf)
add_custom_target(emarb_fonts DEPENDS ${output_path_prefix}/font_awesome.h ${output_path_prefix}/genei_gothic_p_semi_bold.h)
Expand Down
3 changes: 2 additions & 1 deletion emapp/resources/toons/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ function(nanoem_emapp_build_emarb_toon)
add_custom_command(OUTPUT ${output_path_prefix}/${_name}.h
COMMAND ${CMAKE_COMMAND} -E make_directory ${output_path_prefix}
COMMAND ${CMAKE_COMMAND} ARGS -E copy ${_item} ${intermediate_path_prefix}/${_filename}
COMMAND $<TARGET_FILE:emarb_bin2c> --input=${intermediate_path_prefix}/${_filename} --symbol=${_name} --compressed=false
COMMAND ${CMAKE_COMMAND} -E env ASAN_OPTIONS="detect_leaks=0"
$<TARGET_FILE:emarb_bin2c> --input=${intermediate_path_prefix}/${_filename} --symbol=${_name} --compressed=false
> ${output_path_prefix}/${_name}.h
MAIN_DEPENDENCY ${_item})
list(APPEND _sources ${output_path_prefix}/${_name}.h)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# Set-ExecutionPolicy RemoteSigned -Scope Process

$env:NANOEM_DISABLE_BUILD_SENTRY_NATIVE=1
$env:NANOEM_DISABLE_BUILD_TBB=1
$env:NANOEM_TARGET_ARCHITECTURES="arm64"
$env:NANOEM_TARGET_COMPILER="vs2019"
$env:NANOEM_TARGET_GENERATOR="Visual Studio 16 2019"
$env:NANOEM_TARGET_COMPILER="vs2022"
$env:NANOEM_TARGET_GENERATOR="Visual Studio 17 2022"
$build_cmake_path = (Join-Path $PSScriptRoot ../../build.cmake)

cmake -P $build_cmake_path
8 changes: 8 additions & 0 deletions scripts/run/windows/build-vs2022.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Set-ExecutionPolicy RemoteSigned -Scope Process

$env:NANOEM_TARGET_ARCHITECTURES="x86_64"
$env:NANOEM_TARGET_COMPILER="vs2022"
$env:NANOEM_TARGET_GENERATOR="Visual Studio 17 2022"
$build_cmake_path = (Join-Path $PSScriptRoot ../../build.cmake)

cmake -P $build_cmake_path

0 comments on commit 05fcff6

Please sign in to comment.