@ -8,6 +8,47 @@ set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
if ( MSVC OR MSVC_VERSION )
add_compile_options ( /EHca /arch:AVX2 /MD )
add_definitions ( -D_SILENCE_CXX17_OLD_ALLOCATOR_MEMBERS_DEPRECATION_WARNING )
# I f w e ' r e b u i l d i n g a l o k i n e t f o r w i n d o w s , b u t n e e d t o t a r g e t a n c i e n t h a r d w a r e
function ( check_working_cxx_atomics64 varname )
set ( OLD_CMAKE_REQUIRED_FLAGS ${ CMAKE_REQUIRED_FLAGS } )
set ( CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -arch:IA32" )
check_cxx_source_compiles ( "
# i n c l u d e < a t o m i c >
# i n c l u d e < c s t d i n t >
s t d : : a t o m i c < u i n t 6 4 _ t > x ( 0 ) ;
i n t main ( ) {
u i n t 6 4 _ t i = x . load ( std::memory_order_relaxed ) ;
r e t u r n 0 ;
}
" $ { v a r n a m e } )
set ( CMAKE_REQUIRED_FLAGS ${ OLD_CMAKE_REQUIRED_FLAGS } )
endfunction ( )
function ( link_libatomic )
check_working_cxx_atomics64 ( HAVE_CXX_ATOMICS64_WITHOUT_LIB )
if ( HAVE_CXX_ATOMICS64_WITHOUT_LIB )
message ( STATUS "Have working 64bit atomics" )
return ( )
endif ( )
# check_library_exists ( atomic __atomic_load_8 "" HAVE_CXX_LIBATOMICS64 )
# if ( HAVE_CXX_LIBATOMICS64 )
# message ( STATUS "Have 64bit atomics via library" )
# list ( APPEND CMAKE_REQUIRED_LIBRARIES "atomic" )
# check_working_cxx_atomics64 ( HAVE_CXX_ATOMICS64_WITH_LIB )
# if ( HAVE_CXX_ATOMICS64_WITH_LIB )
# message ( STATUS "Can link with libatomic" )
# link_libraries ( -latomic )
# return ( )
# endif ( )
# endif ( )
message ( FATAL_ERROR "Host compiler must support 64-bit std::atomic! (What do, MSVC doesn't emit __atomic_load_x)" )
endfunction ( )
if ( EMBEDDED_CFG )
link_libatomic ( )
endif ( )
if ( ${ CMAKE_CXX_COMPILER_ID } STREQUAL "Clang" AND "x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC" )
add_compile_options ( -Wno-nonportable-system-include-path )
@ -25,8 +66,47 @@ if(NOT MSVC_VERSION)
add_definitions ( -DWINVER=0x0500 -D_WIN32_WINNT=0x0500 )
# W a i t a m i n u t e , i f w e ' r e n o t M i c r o s o f t C + + , n o r a C l a n g p a i r e d w i t h M i c r o s o f t C + + ,
# t h e n t h e o n l y p o s s i b l e o p t i o n h a s t o b e G N U o r a G N U - l i n k e d C l a n g !
if ( NOT CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 9.0 OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang" )
set ( FS_LIB stdc++fs )
set ( FS_LIB stdc++fs )
# I f w e ' r e b u i l d i n g a l o k i n e t f o r w i n d o w s , b u t n e e d t o t a r g e t a n c i e n t h a r d w a r e
function ( check_working_cxx_atomics64 varname )
set ( OLD_CMAKE_REQUIRED_FLAGS ${ CMAKE_REQUIRED_FLAGS } )
set ( CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -march=i486" )
check_cxx_source_compiles ( "
# i n c l u d e < a t o m i c >
# i n c l u d e < c s t d i n t >
s t d : : a t o m i c < u i n t 6 4 _ t > x ( 0 ) ;
i n t main ( ) {
u i n t 6 4 _ t i = x . load ( std::memory_order_relaxed ) ;
r e t u r n 0 ;
}
" $ { v a r n a m e } )
set ( CMAKE_REQUIRED_FLAGS ${ OLD_CMAKE_REQUIRED_FLAGS } )
endfunction ( )
function ( link_libatomic )
check_working_cxx_atomics64 ( HAVE_CXX_ATOMICS64_WITHOUT_LIB )
if ( HAVE_CXX_ATOMICS64_WITHOUT_LIB )
message ( STATUS "Have working 64bit atomics" )
return ( )
endif ( )
check_library_exists ( atomic __atomic_load_8 "" HAVE_CXX_LIBATOMICS64 )
if ( HAVE_CXX_LIBATOMICS64 )
message ( STATUS "Have 64bit atomics via library" )
list ( APPEND CMAKE_REQUIRED_LIBRARIES "atomic" )
check_working_cxx_atomics64 ( HAVE_CXX_ATOMICS64_WITH_LIB )
if ( HAVE_CXX_ATOMICS64_WITH_LIB )
message ( STATUS "Can link with libatomic" )
link_libraries ( -latomic )
return ( )
endif ( )
endif ( )
message ( FATAL_ERROR "Host compiler must support 64-bit std::atomic!" )
endfunction ( )
if ( EMBEDDED_CFG )
link_libatomic ( )
endif ( )
endif ( )