File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -10,6 +10,9 @@ fn main() {
1010
1111 let manifest_dir = PathBuf :: from ( env:: var ( "CARGO_MANIFEST_DIR" ) . unwrap ( ) ) ;
1212
13+ let is_fuzzing = std:: env:: var ( "CARGO_CFG_FUZZING" ) . is_ok ( ) ;
14+ let is_debug_build = std:: env:: var_os ( "OPT_LEVEL" ) . unwrap_or ( "" . into ( ) ) == "0" ;
15+
1316 let mut src_dir = manifest_dir. join ( "cpp" ) ;
1417 if !src_dir. exists ( ) {
1518 src_dir = manifest_dir
@@ -24,6 +27,8 @@ fn main() {
2427 . define ( "BUILD_CHIAVDFC" , "ON" )
2528 . env ( "BUILD_VDF_CLIENT" , "N" )
2629 . define ( "BUILD_PYTHON" , "OFF" )
30+ . define ( "HARDENING" , if is_fuzzing || is_debug_build { "ON" } else { "OFF" } )
31+ . very_verbose ( true )
2732 . build ( ) ;
2833
2934 println ! ( "cargo:rustc-link-lib=static=chiavdfc" ) ;
@@ -48,6 +53,9 @@ fn main() {
4853 . to_str( )
4954 . unwrap( )
5055 ) ;
56+ } else if cfg ! ( target_os = "macos" ) {
57+ println ! ( "cargo:rustc-link-lib=static=gmp" ) ;
58+ println ! ( "cargo:rustc-link-search=native=/opt/homebrew/lib" ) ;
5159 } else {
5260 println ! ( "cargo:rustc-link-lib=gmp" ) ;
5361 }
Original file line number Diff line number Diff line change 11CMAKE_MINIMUM_REQUIRED (VERSION 3.14 FATAL_ERROR )
22option (BUILD_CHIAVDFC "Build the chiavdfc shared library" OFF )
33option (BUILD_PYTHON "Build the python bindings for chiavdf" ON )
4+ option (HARDENING "Enable hardening" OFF )
45
56set (CMAKE_CXX_STANDARD 17)
67set (CMAKE_CXX_STANDARD_REQUIRED ON )
@@ -108,6 +109,11 @@ if(BUILD_CHIAVDFC)
108109 target_link_libraries (chiavdfc_shared ${GMP_LIBRARIES} ${GMPXX_LIBRARIES} )
109110 target_link_libraries (chiavdfc_static ${GMP_LIBRARIES} ${GMPXX_LIBRARIES} )
110111
112+ if (HARDENING)
113+ target_compile_definitions (chiavdfc_shared PRIVATE "_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_DEBUG" )
114+ target_compile_definitions (chiavdfc_static PRIVATE "_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_DEBUG" )
115+ endif ()
116+
111117 set_target_properties (chiavdfc_shared PROPERTIES
112118 OUTPUT_NAME chiavdfc
113119 LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR} /lib/shared$<0:>"
You can’t perform that action at this time.
0 commit comments