diff options
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r-- | CMakeLists.txt | 157 |
1 files changed, 98 insertions, 59 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index ae042706a..5b15eb667 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -177,7 +177,38 @@ IF(CMAKE_SYSTEM_NAME STREQUAL "Linux") ENDIF(CMAKE_SYSTEM_NAME STREQUAL "Linux") IF(CMAKE_SYSTEM_NAME STREQUAL "SunOS") - SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_GNU_SOURCE -DSOLARIS") + IF(NOT BUILD_CPU_MODE) + SET (BUILD_CPU_MODE "32") + ENDIF(NOT BUILD_CPU_MODE) + + IF("${CMAKE_C_COMPILER_ID}" MATCHES SunPro) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Xa -xregs=no%frameptr -xstrconst") + set(SUN_BUILD32 "-xtarget=generic") + set(SUN_BUILD64 "-xtagret=generic64") + IF(ENABLE_OPTIMIZATION MATCHES "ON") + SET(CMAKE_C_OPT_FLAGS "-fast -xdepend") + ELSE(ENABLE_OPTIMIZATION MATCHES "ON") + SET(CMAKE_C_OPT_FLAGS "-xO0") + ENDIF(ENABLE_OPTIMIZATION MATCHES "ON") + ELSE("${CMAKE_C_COMPILER_ID}" MATCHES SunPro) + set(SUN_BUILD32 "-m32") + set(SUN_BUILD64 "-m64") + ENDIF("${CMAKE_C_COMPILER_ID}" MATCHES SunPro) + + IF (BUILD_CPU_MODE STREQUAL "32") + message (STATUS "Building 32-bit mode on Solaris") + # If we are asked to build 32 bit mode + set(CMAKE_C_FLAGS "${SUN_BUILD32} ${CMAKE_C_FLAGS}") + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${SUN_BUILD32}") + ELSE (BUILD_CPU_MODE STREQUAL "32") + # solaris 64-bit mode + message (STATUS "Building 64-bit mode on Solaris") + set(CMAKE_C_FLAGS "${SUN_BUILD64} ${CMAKE_C_FLAGS}") + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${SUN_BUILD64}") + ENDIF (BUILD_CPU_MODE STREQUAL "32") + + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D__EXTENSIONS__ -DSOLARIS") + IF(CMAKE_INSTALL_PREFIX) IF(NOT ETC_PREFIX) SET(ETC_PREFIX "${CMAKE_INSTALL_PREFIX}/etc") @@ -194,7 +225,7 @@ IF(CMAKE_SYSTEM_NAME STREQUAL "SunOS") SET(ETC_PREFIX /etc) ENDIF(NOT ETC_PREFIX) IF(NOT PREFIX) - SET(PREFIX /opt/rspamd) + SET(PREFIX /usr) ENDIF(NOT PREFIX) IF(NOT MAN_PREFIX) SET(MAN_PREFIX /usr/share/man) @@ -207,8 +238,11 @@ IF(CMAKE_SYSTEM_NAME STREQUAL "SunOS") LIST(APPEND CMAKE_REQUIRED_LIBRARIES rt) LIST(APPEND CMAKE_REQUIRED_LIBRARIES dl) LIST(APPEND CMAKE_REQUIRED_LIBRARIES resolv) - LIST(APPEND CMAKE_REQUIRED_LIBRARIES m) - MESSAGE(STATUS "Configuring for Solaris") + LIST(APPEND CMAKE_REQUIRED_LIBRARIES nsl) + LIST(APPEND CMAKE_REQUIRED_LIBRARIES umem) + SET(CMAKE_VERBOSE_MAKEFILE ON) + SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH FALSE) + SET(CMAKE_INSTALL_RPATH "${PREFIX}/lib") ENDIF(CMAKE_SYSTEM_NAME STREQUAL "SunOS") # Check prefixes @@ -498,7 +532,64 @@ IF(LIBUTIL_LIBRARY) DOC "Path to libutil header") ENDIF(LIBUTIL_LIBRARY) + # Process with warn flags + IF(CMAKE_COMPILER_IS_GNUCC) + CHECK_C_COMPILER_FLAG(-Wall SUPPORT_WALL) + CHECK_C_COMPILER_FLAG(-Wall SUPPORT_W) + CHECK_C_COMPILER_FLAG(-Wpointer-arith SUPPORT_WPOINTER) + CHECK_C_COMPILER_FLAG(-Wno-unused-parameter SUPPORT_WPARAM) + CHECK_C_COMPILER_FLAG(-Wno-unused-function SUPPORT_WFUNCTION) + CHECK_C_COMPILER_FLAG(-Wunused-variable SUPPORT_WUNUSED_VAR) + CHECK_C_COMPILER_FLAG(-Wno-pointer-sign SUPPORT_WPOINTER_SIGN) + CHECK_C_COMPILER_FLAG(-pedantic SUPPORT_PEDANTIC_FLAG) + CHECK_C_COMPILER_FLAG("-std=c99" SUPPORT_STD_FLAG) + + SET(CMAKE_C_WARN_FLAGS "") + + IF(SUPPORT_W) + SET(CMAKE_C_WARN_FLAGS "${CMAKE_C_WARN_FLAGS} -W") + ENDIF(SUPPORT_W) + IF(SUPPORT_WALL) + SET(CMAKE_C_WARN_FLAGS "${CMAKE_C_WARN_FLAGS} -Wall") + ENDIF(SUPPORT_WALL) + IF(SUPPORT_WPOINTER) + SET(CMAKE_C_WARN_FLAGS "${CMAKE_C_WARN_FLAGS} -Wpointer-arith") + ENDIF(SUPPORT_WPOINTER) + IF(SUPPORT_WPARAM) + SET(CMAKE_C_WARN_FLAGS "${CMAKE_C_WARN_FLAGS} -Wno-unused-parameter") + ENDIF(SUPPORT_WPARAM) + IF(SUPPORT_WFUNCTION) + SET(CMAKE_C_WARN_FLAGS "${CMAKE_C_WARN_FLAGS} -Wno-unused-function") + ENDIF(SUPPORT_WFUNCTION) + IF(SUPPORT_WUNUSED_VAR) + SET(CMAKE_C_WARN_FLAGS "${CMAKE_C_WARN_FLAGS} -Wunused-variable") + ENDIF(SUPPORT_WUNUSED_VAR) + IF(SUPPORT_WPOINTER_SIGN) + SET(CMAKE_C_WARN_FLAGS "${CMAKE_C_WARN_FLAGS} -Wno-pointer-sign") + ENDIF(SUPPORT_WPOINTER_SIGN) + IF(SUPPORT_PEDANTIC_FLAG) + SET(CMAKE_C_WARN_FLAGS "${CMAKE_C_WARN_FLAGS} -pedantic") + ENDIF(SUPPORT_PEDANTIC_FLAG) + IF(SUPPORT_STD_FLAG) + SET(CMAKE_C_WARN_FLAGS "${CMAKE_C_WARN_FLAGS} -std=c99") + ENDIF(SUPPORT_STD_FLAG) + ENDIF(CMAKE_COMPILER_IS_GNUCC) + + # Optimization flags +IF(NOT CMAKE_C_OPT_FLAGS) + IF(ENABLE_OPTIMIZATION MATCHES "ON") + SET(CMAKE_C_OPT_FLAGS "-O3") + ELSE(ENABLE_OPTIMIZATION MATCHES "ON") + SET(CMAKE_C_OPT_FLAGS "-O0") + ENDIF(ENABLE_OPTIMIZATION MATCHES "ON") +ENDIF(NOT CMAKE_C_OPT_FLAGS) + +IF(DEBUG_MODE MATCHES "ON") + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g") +ENDIF(DEBUG_MODE MATCHES "ON") +SET(CMAKE_C_FLAGS "${CMAKE_C_OPT_FLAGS} ${CMAKE_C_FLAGS} ${CMAKE_C_WARN_FLAGS}") + # Check platform specific includes CHECK_INCLUDE_FILES(sys/types.h HAVE_SYS_TYPES_H) CHECK_INCLUDE_FILES(sys/time.h HAVE_SYS_TIME_H) @@ -574,8 +665,9 @@ CHECK_SYMBOL_EXISTS(MAP_SHARED sys/mman.h HAVE_MMAP_SHARED) CHECK_SYMBOL_EXISTS(MAP_ANON sys/mman.h HAVE_MMAP_ANON) CHECK_SYMBOL_EXISTS(MAP_NOCORE sys/mman.h HAVE_MMAP_NOCORE) CHECK_SYMBOL_EXISTS(_SC_NPROCESSORS_ONLN unistd.h HAVE_SC_NPROCESSORS_ONLN) -CHECK_SYMBOL_EXISTS(SA_SIGINFO signal.h HAVE_SA_SIGINFO) +CHECK_SYMBOL_EXISTS(SA_SIGINFO "signal.h;siginfo.h" HAVE_SA_SIGINFO) +IF(NOT CMAKE_SYSTEM_NAME STREQUAL "SunOS") IF(HAVE_CLOCK_GETTIME) CHECK_SYMBOL_EXISTS(CLOCK_PROCESS_CPUTIME_ID time.h HAVE_CLOCK_PROCESS_CPUTIME_ID) CHECK_SYMBOL_EXISTS(CLOCK_VIRTUAL time.h HAVE_CLOCK_VIRTUAL) @@ -589,6 +681,7 @@ CHECK_C_SOURCE_COMPILES ("#include <sys/types.h> __asm __volatile(\"pause\"); return 0; }" HAVE_ASM_PAUSE) +ENDIF(NOT CMAKE_SYSTEM_NAME STREQUAL "SunOS") # Check queue.h compatibility IF(NOT HAVE_COMPATIBLE_QUEUE_H) @@ -598,60 +691,6 @@ ENDIF(NOT HAVE_COMPATIBLE_QUEUE_H) SET(CONTRIBSRC "") -# Optimization flags -IF(ENABLE_OPTIMIZATION MATCHES "ON") - SET(CMAKE_C_OPT_FLAGS "-O3") -ELSE(ENABLE_OPTIMIZATION MATCHES "ON") - SET(CMAKE_C_OPT_FLAGS "-O0") -ENDIF(ENABLE_OPTIMIZATION MATCHES "ON") - -# Process with warn flags -CHECK_C_COMPILER_FLAG(-Wall SUPPORT_WALL) -CHECK_C_COMPILER_FLAG(-Wall SUPPORT_W) -CHECK_C_COMPILER_FLAG(-Wpointer-arith SUPPORT_WPOINTER) -CHECK_C_COMPILER_FLAG(-Wno-unused-parameter SUPPORT_WPARAM) -CHECK_C_COMPILER_FLAG(-Wno-unused-function SUPPORT_WFUNCTION) -CHECK_C_COMPILER_FLAG(-Wunused-variable SUPPORT_WUNUSED_VAR) -CHECK_C_COMPILER_FLAG(-Wno-pointer-sign SUPPORT_WPOINTER_SIGN) -CHECK_C_COMPILER_FLAG(-pedantic SUPPORT_PEDANTIC_FLAG) -CHECK_C_COMPILER_FLAG("-std=c99" SUPPORT_STD_FLAG) - -SET(CMAKE_C_WARN_FLAGS "") - -IF(SUPPORT_W) - SET(CMAKE_C_WARN_FLAGS "${CMAKE_C_WARN_FLAGS} -W") -ENDIF(SUPPORT_W) -IF(SUPPORT_WALL) - SET(CMAKE_C_WARN_FLAGS "${CMAKE_C_WARN_FLAGS} -Wall") -ENDIF(SUPPORT_WALL) -IF(SUPPORT_WPOINTER) - SET(CMAKE_C_WARN_FLAGS "${CMAKE_C_WARN_FLAGS} -Wpointer-arith") -ENDIF(SUPPORT_WPOINTER) -IF(SUPPORT_WPARAM) - SET(CMAKE_C_WARN_FLAGS "${CMAKE_C_WARN_FLAGS} -Wno-unused-parameter") -ENDIF(SUPPORT_WPARAM) -IF(SUPPORT_WFUNCTION) - SET(CMAKE_C_WARN_FLAGS "${CMAKE_C_WARN_FLAGS} -Wno-unused-function") -ENDIF(SUPPORT_WFUNCTION) -IF(SUPPORT_WUNUSED_VAR) - SET(CMAKE_C_WARN_FLAGS "${CMAKE_C_WARN_FLAGS} -Wunused-variable") -ENDIF(SUPPORT_WUNUSED_VAR) -IF(SUPPORT_WPOINTER_SIGN) - SET(CMAKE_C_WARN_FLAGS "${CMAKE_C_WARN_FLAGS} -Wno-pointer-sign") -ENDIF(SUPPORT_WPOINTER_SIGN) -IF(SUPPORT_PEDANTIC_FLAG) - SET(CMAKE_C_WARN_FLAGS "${CMAKE_C_WARN_FLAGS} -pedantic") -ENDIF(SUPPORT_PEDANTIC_FLAG) -IF(SUPPORT_STD_FLAG) - SET(CMAKE_C_WARN_FLAGS "${CMAKE_C_WARN_FLAGS} -std=c99") -ENDIF(SUPPORT_STD_FLAG) - -SET(CMAKE_C_FLAGS "${CMAKE_C_OPT_FLAGS} ${CMAKE_C_FLAGS} ${CMAKE_C_WARN_FLAGS}") - -IF(DEBUG_MODE MATCHES "ON") - SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g") -ENDIF(DEBUG_MODE MATCHES "ON") - IF(NOT DESTDIR) SET(DESTDIR $ENV{DESTDIR}) ENDIF(NOT DESTDIR) |