@@ -7,15 +7,15 @@ project(hash_dumper
77)
88
99# Initializing parameters
10- option (DEBUG "Sets compilation flags for debugging" OFF )
11- option (RELEASE "Sets compilation flags for optimized binary" OFF )
12- option (BUILD32 "Sets compilation flags for 32-bit mode" OFF )
1310set (INSTALL_PREFIX /usr/local/bin CACHE PATH "Path for installed binaries" )
11+ set (BUILD_ARCH "amd64" CACHE STRING "Build architecture amd64/i386" )
12+ set (BUILD_CPU "RELEASE" CACHE STRING "Build target mode RELEASE/DEBUG" )
1413
1514# Checking parameters
1615set (CMAKE_INSTALL_PREFIX ${INSTALL_PREFIX} )
1716
18- if ((DEBUG) AND (NOT RELEASE))
17+ # Add debug flags
18+ if (BUILD_TARGET STREQUAL "DEBUG" )
1919 if (CMAKE_C_COMPILER_ID STREQUAL "GNU" )
2020 add_compile_options (-O0 )
2121 add_compile_options (-ggdb )
@@ -32,17 +32,28 @@ if ((DEBUG) AND (NOT RELEASE))
3232
3333endif ()
3434
35- if ((NOT DEBUG) AND (RELEASE))
35+ # Add release flags
36+ if (BUILD_TARGET STREQUAL "RELEASE" )
3637 message (STATUS "Enabled release with -O3" )
3738 add_compile_options (-O3 )
39+ add_compile_options (-s )
3840endif ()
3941
40- if (BUILD32)
41- message (STATUS "Enabled 32-bit mode" )
42+ # Process build architectures
43+ if (BUILD_ARCH STREQUAL "amd64" )
44+ message (STATUS "Build amd64 binary" )
45+ add_compile_options (-m64 )
46+ add_link_options (-m64 )
47+ set (CMAKE_LIBRARY_PATH /usr/lib/x86_64-linux -gnu)
48+ include_directories (BEFORE /usr/include/x86_64-linux-gnu )
49+ elseif (BUILD_ARCH STREQUAL "i386" )
50+ message (STATUS "Build i386 binary" )
4251 add_compile_options (-m32 )
4352 add_link_options (-m32 )
44- SET (CMAKE_LIBRARY_PATH " /usr/lib/i386-linux-gnu" )
53+ set (CMAKE_LIBRARY_PATH /usr/lib/i386-linux -gnu)
4554 include_directories (BEFORE /usr/include/i386-linux-gnu )
55+ else ()
56+ message (FATAL_ERROR "Unknown building architecture ${BUILD_ARCH} " )
4657endif ()
4758
4859# Source code paths
@@ -70,14 +81,14 @@ install(TARGETS ${PROJECT_NAME} DESTINATION .)
7081message (STATUS "WARNING! Installation prefix ${CMAKE_INSTALL_PREFIX} " )
7182
7283# Cleanup cache
73- unset (DEBUG CACHE )
74- unset (RELEASE CACHE )
75- unset (BUILD32 CACHE )
7684unset (INSTALL_PREFIX CACHE )
85+ unset (BUILD_ARCH CACHE )
86+ unset (BUILD_TARGET CACHE )
7787
7888unset (CMAKE_LIBRARY_PATH CACHE )
7989unset (CMAKE_INSTALL_PREFIX CACHE )
8090
91+ # Clear OpenSSL references
8192unset (OPENSSL_FOUND CACHE )
8293unset (OPENSSL_INCLUDE_DIR CACHE )
8394unset (OPENSSL_CRYPTO_LIBRARY CACHE )
0 commit comments