cmake_minimum_required(VERSION 3.11) enable_language(CXX) project(General) # ----------------------------------------------------------------------------- # O/S Detection # these are defined in common.h too SET(LINUX False) SET(FREEBSD False) SET(MACOS False) # Detect the operating system IF(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") SET(TARGET_OS_NAME "macos") SET(TARGET_OS 3) SET(MACOS True) ELSEIF(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD") SET(TARGET_OS_NAME "freebsd") SET(TARGET_OS 2) SET(FREEBSD True) ELSE() SET(TARGET_OS_NAME "linux") SET(TARGET_OS 1) SET(LINUX True) ENDIF() # show the operating system on the console message(STATUS "operating system: ${TARGET_OS_NAME} (TARGET_OS=${TARGET_OS})") message( "current compiler " ${CMAKE_CXX_COMPILER_ID}) if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") # using Clang elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") add_compile_options(-Wall) add_compile_options(-Wsign-compare) add_compile_options(-Werror) add_compile_options(-Wno-unused-function) add_compile_options(-Wno-misleading-indentation) add_compile_options(-Wno-format-overflow) # using GCC elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel") # using Intel C++ elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") # using Visual Studio C++ aux_source_directory(src DIRSRCS) aux_source_directory(src/pattern PaternSrc) aux_source_directory(src/function FunctionSrc) aux_source_directory(src/algorithm AlgorithmSrc) aux_source_directory(src/encrypt EncryptSrc) add_compile_options( /DEBUG /D_CRT_SECURE_NO_WARNINGS /D_CRT_SECURE_NO_WARNINGS) add_library(General OBJECT ${DIRSRCS} ${PaternSrc} ${EncryptSrc} ${FunctionSrc} ${AlgorithmSrc} ) set_property(TARGET General PROPERTY MSVC_RUNTIME_LIBRARY MultiThreadedDebug) elseif("AppleClang" STREQUAL ${CMAKE_CXX_COMPILER_ID}) message("apple clang compiler") aux_source_directory(src DIRSRCS) aux_source_directory(src/pattern PaternSrc) # aux_source_directory(src/function FunctionSrc) aux_source_directory(src/algorithm AlgorithmSrc) aux_source_directory(src/encrypt EncryptSrc) add_library(General OBJECT ${DIRSRCS} ${PaternSrc} ${EncryptSrc} ${FunctionSrc} ${AlgorithmSrc} ) set_property(TARGET General PROPERTY MSVC_RUNTIME_LIBRARY MultiThreadedDebug) endif() SET(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/obj) message( "LIBRARY_OUTPUT_PATH " ${LIBRARY_OUTPUT_PATH}) set(CMAKE_CXX_STANDARD 11) INCLUDE_DIRECTORIES (./) INCLUDE_DIRECTORIES (inc) INCLUDE_DIRECTORIES (encrypt) INCLUDE_DIRECTORIES (pattern) include_directories(third/include) message("source file is " ${DIRSRCS} ${PaternSrc} ${EncryptSrc} ${FunctionSrc} ${AlgorithmSrc})