lets just do that
This commit is contained in:
parent
c88ab93a10
commit
96eb9c99dd
|
@ -10,52 +10,54 @@ function(ssxtools_target target)
|
||||||
target_compile_features(${target} PUBLIC cxx_std_20)
|
target_compile_features(${target} PUBLIC cxx_std_20)
|
||||||
|
|
||||||
# some sane compiler flags
|
# some sane compiler flags
|
||||||
set(_CORE_COMPILE_ARGS -Wall -Wextra)
|
if(NOT WIN32)
|
||||||
set(_CORE_LINKER_ARGS "")
|
set(_CORE_COMPILE_ARGS -Wall -Wextra)
|
||||||
|
set(_CORE_LINKER_ARGS "")
|
||||||
|
|
||||||
if("${CMAKE_BUILD_TYPE}" STREQUAL "Release")
|
if("${CMAKE_BUILD_TYPE}" STREQUAL "Release")
|
||||||
set(_CORE_COMPILE_ARGS ${_CORE_COMPILE_ARGS} -Werror)
|
set(_CORE_COMPILE_ARGS ${_CORE_COMPILE_ARGS} -Werror)
|
||||||
|
|
||||||
# If on Release use link-time optimizations.
|
# If on Release use link-time optimizations.
|
||||||
# On clang we use ThinLTO for even better build performance.
|
# On clang we use ThinLTO for even better build performance.
|
||||||
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
||||||
set(_CORE_COMPILE_ARGS ${_CORE_COMPILE_ARGS} -flto=thin)
|
set(_CORE_COMPILE_ARGS ${_CORE_COMPILE_ARGS} -flto=thin)
|
||||||
set(_CORE_LINKER_ARGS ${_CORE_LINKER_ARGS} -flto=thin)
|
set(_CORE_LINKER_ARGS ${_CORE_LINKER_ARGS} -flto=thin)
|
||||||
target_link_options(${target} PRIVATE -fuse-ld=${SSXTOOLS_LINKER} -flto=thin)
|
target_link_options(${target} PRIVATE -fuse-ld=${SSXTOOLS_LINKER} -flto=thin)
|
||||||
else()
|
else("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
|
||||||
set(_CORE_COMPILE_ARGS ${_CORE_COMPILE_ARGS} -flto)
|
set(_CORE_COMPILE_ARGS ${_CORE_COMPILE_ARGS} -flto)
|
||||||
set(_CORE_LINKER_ARGS ${_CORE_LINKER_ARGS} -flto)
|
set(_CORE_LINKER_ARGS ${_CORE_LINKER_ARGS} -flto)
|
||||||
target_link_options(${target} PRIVATE -fuse-ld=${SSXTOOLS_LINKER} -flto)
|
target_link_options(${target} PRIVATE -fuse-ld=${SSXTOOLS_LINKER} -flto)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if("asan" IN_LIST SSXTOOLS_BUILD_FEATURES)
|
if("asan" IN_LIST SSXTOOLS_BUILD_FEATURES)
|
||||||
# Error if someone's trying to mix asan and tsan together,
|
# Error if someone's trying to mix asan and tsan together,
|
||||||
# they aren't compatible.
|
# they aren't compatible.
|
||||||
if("tsan" IN_LIST SSXTOOLS_BUILD_FEATURES)
|
if("tsan" IN_LIST SSXTOOLS_BUILD_FEATURES)
|
||||||
message(FATAL_ERROR "ASAN and TSAN cannot be used together.")
|
message(FATAL_ERROR "ASAN and TSAN cannot be used together.")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
message(STATUS "Enabling ASAN for target ${target}")
|
message(STATUS "Enabling ASAN for target ${target}")
|
||||||
set(_CORE_COMPILE_ARGS ${_CORE_COMPILE_ARGS} -fsanitize=address)
|
set(_CORE_COMPILE_ARGS ${_CORE_COMPILE_ARGS} -fsanitize=address)
|
||||||
set(_CORE_LINKER_ARGS ${_CORE_LINKER_ARGS} -fsanitize=address)
|
set(_CORE_LINKER_ARGS ${_CORE_LINKER_ARGS} -fsanitize=address)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if("tsan" IN_LIST SSXTOOLS_BUILD_FEATURES)
|
if("tsan" IN_LIST SSXTOOLS_BUILD_FEATURES)
|
||||||
message(STATUS "Enabling TSAN for target ${target}")
|
message(STATUS "Enabling TSAN for target ${target}")
|
||||||
set(_CORE_COMPILE_ARGS ${_CORE_COMPILE_ARGS} -fsanitize=thread)
|
set(_CORE_COMPILE_ARGS ${_CORE_COMPILE_ARGS} -fsanitize=thread)
|
||||||
set(_CORE_LINKER_ARGS ${_CORE_LINKER_ARGS} -fsanitize=thread)
|
set(_CORE_LINKER_ARGS ${_CORE_LINKER_ARGS} -fsanitize=thread)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if("ubsan" IN_LIST SSXTOOLS_BUILD_FEATURES)
|
if("ubsan" IN_LIST SSXTOOLS_BUILD_FEATURES)
|
||||||
message(STATUS "Enabling UBSAN for target ${target}")
|
message(STATUS "Enabling UBSAN for target ${target}")
|
||||||
set(_CORE_COMPILE_ARGS ${_CORE_COMPILE_ARGS} -fsanitize=undefined)
|
set(_CORE_COMPILE_ARGS ${_CORE_COMPILE_ARGS} -fsanitize=undefined)
|
||||||
set(_CORE_LINKER_ARGS ${_CORE_LINKER_ARGS} -fsanitize=undefined)
|
set(_CORE_LINKER_ARGS ${_CORE_LINKER_ARGS} -fsanitize=undefined)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
target_compile_options(${target} PRIVATE ${_CORE_COMPILE_ARGS})
|
target_compile_options(${target} PRIVATE ${_CORE_COMPILE_ARGS})
|
||||||
target_link_options(${target} PRIVATE ${_CORE_LINKER_ARGS})
|
target_link_options(${target} PRIVATE ${_CORE_LINKER_ARGS})
|
||||||
|
endif()
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
function(ssxtools_header_only_target target)
|
function(ssxtools_header_only_target target)
|
||||||
|
@ -64,10 +66,12 @@ function(ssxtools_header_only_target target)
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
function(ssxtools_set_alternate_linker)
|
function(ssxtools_set_alternate_linker)
|
||||||
find_program(LINKER_EXECUTABLE ld.${SSXTOOLS_LINKER} ${SSXTOOLS_LINKER})
|
if(NOT WIN32)
|
||||||
if(LINKER_EXECUTABLE)
|
find_program(LINKER_EXECUTABLE ld.${SSXTOOLS_LINKER} ${SSXTOOLS_LINKER})
|
||||||
message(STATUS "Using ${SSXTOOLS_LINKER} as linker for ssxtools projects")
|
if(LINKER_EXECUTABLE)
|
||||||
else()
|
message(STATUS "Using ${SSXTOOLS_LINKER} as linker for ssxtools projects")
|
||||||
message(FATAL_ERROR "Linker ${SSXTOOLS_LINKER} does not exist on your system. Please specify one which does or omit this option from your configure command.")
|
else()
|
||||||
endif()
|
message(FATAL_ERROR "Linker ${SSXTOOLS_LINKER} does not exist on your system. Please specify one which does or omit this option from your configure command.")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
|
@ -97,7 +97,7 @@ void ThreadFunction(char prefix) {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
int main(int argc, char** argv) {
|
int main() {
|
||||||
asio::io_context ioc;
|
asio::io_context ioc;
|
||||||
|
|
||||||
asio::thread_pool pool(26);
|
asio::thread_pool pool(26);
|
||||||
|
|
Loading…
Reference in New Issue