git-svn-id: svn://db.shs.com.ru/pip@349 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5
This commit is contained in:
201
CMakeLists.txt
201
CMakeLists.txt
@@ -35,16 +35,17 @@ option(ICU "Unicode support" 1)
|
||||
option(USB "USB support" 0)
|
||||
option(STL "Building with STL containers" 0)
|
||||
option(CRYPT "Crypt support" 0)
|
||||
option(FFTW "fftw3 support for PIFFT" 1)
|
||||
option(FFTW "fftw3 support for PIFFT" 0)
|
||||
option(FFTW_THREADS "fftw3 support for threadsave" 1)
|
||||
option(INTROSPECTION_CONTAINERS "Build with containers introspection" 0)
|
||||
option(INTROSPECTION_THREADS "Build with threads introspection" 0)
|
||||
option(LIB "System install" 1)
|
||||
option(DEBUG "Build with -g3" 0)
|
||||
set(CMAKE_BUILD_TYPE "Release")
|
||||
set(LIBS)
|
||||
if (DEBUG)
|
||||
if(DEBUG)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g3")
|
||||
endif ()
|
||||
endif()
|
||||
|
||||
# Sources
|
||||
set(PIP_FOLDERS "." "core" "containers" "thread" "system" "io" "console" "math" "code" "geo")
|
||||
@@ -69,148 +70,168 @@ CHECK_FUNCTION_EXISTS(jn PIP_MATH_JN)
|
||||
CHECK_FUNCTION_EXISTS(y0 PIP_MATH_Y0)
|
||||
CHECK_FUNCTION_EXISTS(y1 PIP_MATH_Y1)
|
||||
CHECK_FUNCTION_EXISTS(yn PIP_MATH_YN)
|
||||
if (PIP_MATH_J0)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DPIP_MATH_J0")
|
||||
endif ()
|
||||
if (PIP_MATH_J1)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DPIP_MATH_J1")
|
||||
endif ()
|
||||
if (PIP_MATH_JN)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DPIP_MATH_JN")
|
||||
endif ()
|
||||
if (PIP_MATH_Y0)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DPIP_MATH_Y0")
|
||||
endif ()
|
||||
if (PIP_MATH_Y1)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DPIP_MATH_Y1")
|
||||
endif ()
|
||||
if (PIP_MATH_YN)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DPIP_MATH_YN")
|
||||
endif ()
|
||||
if(PIP_MATH_J0)
|
||||
add_definitions(-DPIP_MATH_J0)
|
||||
endif()
|
||||
if(PIP_MATH_J1)
|
||||
add_definitions(-DPIP_MATH_J1)
|
||||
endif()
|
||||
if(PIP_MATH_JN)
|
||||
add_definitions(-DPIP_MATH_JN)
|
||||
endif()
|
||||
if(PIP_MATH_Y0)
|
||||
add_definitions(-DPIP_MATH_Y0)
|
||||
endif()
|
||||
if(PIP_MATH_Y1)
|
||||
add_definitions(-DPIP_MATH_Y1)
|
||||
endif()
|
||||
if(PIP_MATH_YN)
|
||||
add_definitions(-DPIP_MATH_YN)
|
||||
endif()
|
||||
|
||||
if(WIN32)
|
||||
list(APPEND CMAKE_LIBRARY_PATH ${MINGW_LIB})
|
||||
endif()
|
||||
|
||||
# Check if RT timers exists
|
||||
set(CMAKE_REQUIRED_INCLUDES time.h)
|
||||
if (DEFINED ENV{QNX_HOST})
|
||||
set(CMAKE_REQUIRED_LIBRARIES )
|
||||
else ()
|
||||
set(CMAKE_REQUIRED_LIBRARIES rt)
|
||||
endif ()
|
||||
if(NOT DEFINED ENV{QNX_HOST} AND NOT APPLE AND NOT WIN32)
|
||||
list(APPEND LIBS rt)
|
||||
endif()
|
||||
CHECK_FUNCTION_EXISTS(timer_create PIP_TIMER_RT_0)
|
||||
CHECK_FUNCTION_EXISTS(timer_settime PIP_TIMER_RT_1)
|
||||
CHECK_FUNCTION_EXISTS(timer_delete PIP_TIMER_RT_2)
|
||||
if (PIP_TIMER_RT_0 AND PIP_TIMER_RT_1 AND PIP_TIMER_RT_2)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DPIP_TIMER_RT")
|
||||
if(PIP_TIMER_RT_0 AND PIP_TIMER_RT_1 AND PIP_TIMER_RT_2)
|
||||
add_definitions(-DPIP_TIMER_RT)
|
||||
message(STATUS "Available timers: Thread, ThreadRT, Pool")
|
||||
else ()
|
||||
else()
|
||||
message(STATUS "Available timers: Thread, Pool")
|
||||
endif ()
|
||||
endif()
|
||||
|
||||
|
||||
# Check if USB is on (to enable use "-DUSB=" argument of cmake)
|
||||
if (USB)
|
||||
if(USB)
|
||||
message(STATUS "Building with USB support")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DPIP_USB")
|
||||
add_definitions(-DPIP_USB)
|
||||
list(APPEND LIBS usb)
|
||||
else ()
|
||||
else()
|
||||
message(STATUS "Building without USB support")
|
||||
endif ()
|
||||
endif()
|
||||
|
||||
|
||||
# Check if STL containers is on (to enable use "-DSTL=" argument of cmake)
|
||||
if (STL)
|
||||
if(STL)
|
||||
message(STATUS "Building with STL containers")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DPIP_CONTAINERS_STL")
|
||||
else ()
|
||||
add_definitions(-DPIP_CONTAINERS_STL)
|
||||
else()
|
||||
message(STATUS "Building with PIP containers")
|
||||
endif ()
|
||||
endif()
|
||||
|
||||
|
||||
# Check if ICU used for PIString and PIChar
|
||||
if (ICU)
|
||||
if(ICU)
|
||||
message(STATUS "Building with ICU")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DPIP_ICU")
|
||||
add_definitions(-DPIP_ICU)
|
||||
list(APPEND LIBS icuuc)
|
||||
else ()
|
||||
else()
|
||||
message(STATUS "Building without ICU, attention!")
|
||||
endif ()
|
||||
endif()
|
||||
|
||||
|
||||
# Check if PIP support cryptographic encryption/decryption by using sodium library
|
||||
if (CRYPT)
|
||||
if(CRYPT)
|
||||
message(STATUS "Building with crypt support")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DPIP_CRYPT")
|
||||
add_definitions(-DPIP_CRYPT)
|
||||
list(APPEND LIBS sodium)
|
||||
else ()
|
||||
else()
|
||||
message(STATUS "Building without crypt support")
|
||||
endif ()
|
||||
endif()
|
||||
|
||||
|
||||
# Check if PIP support fftw3 for PIFFT using in math module
|
||||
if (FFTW)
|
||||
if(FFTW)
|
||||
message(STATUS "Building with fftw3 support")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DPIP_FFTW")
|
||||
if (WIN32)
|
||||
add_definitions(-DPIP_FFTW)
|
||||
if(WIN32)
|
||||
add_definitions(-DPIP_FFTW_THREADSAFE)
|
||||
list(APPEND LIBS fftw3-3 fftw3f-3 fftw3l-3)
|
||||
else ()
|
||||
list(APPEND LIBS fftw3 fftw3f fftw3_threads fftw3f_threads)
|
||||
endif ()
|
||||
else ()
|
||||
else()
|
||||
list(APPEND LIBS fftw3 fftw3f)
|
||||
if(FFTW_THREADS)
|
||||
add_definitions(-DPIP_FFTW_THREADSAFE)
|
||||
list(APPEND LIBS fftw3_threads fftw3f_threads)
|
||||
endif()
|
||||
endif()
|
||||
else()
|
||||
message(STATUS "Building without fftw3 support")
|
||||
endif ()
|
||||
endif()
|
||||
|
||||
|
||||
# Check if PIP should be built with containers introspection
|
||||
if (INTROSPECTION_CONTAINERS)
|
||||
if(INTROSPECTION_CONTAINERS)
|
||||
message(STATUS "Building with containers introspection")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DPIP_INTROSPECTION_CONTAINERS")
|
||||
else ()
|
||||
add_definitions(-DPIP_INTROSPECTION_CONTAINERS)
|
||||
else()
|
||||
message(STATUS "Building without containers introspection")
|
||||
endif ()
|
||||
endif()
|
||||
|
||||
|
||||
# Check if PIP should be built with threads introspection
|
||||
if (INTROSPECTION_THREADS)
|
||||
if(INTROSPECTION_THREADS)
|
||||
message(STATUS "Building with threads introspection")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DPIP_INTROSPECTION_THREADS")
|
||||
else ()
|
||||
add_definitions(-DPIP_INTROSPECTION_THREADS)
|
||||
else()
|
||||
message(STATUS "Building without threads introspection")
|
||||
endif ()
|
||||
endif()
|
||||
|
||||
|
||||
# Add library
|
||||
if (APPLE)
|
||||
if(APPLE)
|
||||
add_definitions(-D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE)
|
||||
endif ()
|
||||
if (WIN32)
|
||||
endif()
|
||||
if(WIN32)
|
||||
list(APPEND LIBS ws2_32 iphlpapi psapi)
|
||||
else()
|
||||
list(APPEND LIBS dl)
|
||||
if(DEFINED ENV{QNX_HOST})
|
||||
list(APPEND LIBS socket)
|
||||
else()
|
||||
list(APPEND LIBS pthread util)
|
||||
endif()
|
||||
endif()
|
||||
foreach(LIB_ ${LIBS})
|
||||
find_library("${LIB_}_FOUND" ${LIB_})
|
||||
message(STATUS "Check the ${LIB_} is installed: " ${${LIB_}_FOUND})
|
||||
if("${${LIB_}_FOUND}" STREQUAL "${LIB_}_FOUND-NOTFOUND")
|
||||
message(WARNING "library ${LIB_} not found, please install it")
|
||||
else()
|
||||
list(APPEND LIBS ${LIB_})
|
||||
list(APPEND CMAKE_REQUIRED_LIBRARIES ${LIB_})
|
||||
endif()
|
||||
endforeach()
|
||||
if(WIN32)
|
||||
list(APPEND CPPS "pip_resource_win.rc")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DPSAPI_VERSION=1")
|
||||
add_definitions(-DPSAPI_VERSION=1)
|
||||
add_library(pip SHARED ${CPPS} ${HDRS} ${PHDRS})
|
||||
if (${CMAKE_C_COMPILER} STREQUAL "cl")
|
||||
if(${CMAKE_C_COMPILER} STREQUAL "cl")
|
||||
include(GenerateExportHeader)
|
||||
generate_export_header(pip)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /O2 /Ob2 /Ot")
|
||||
else ()
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3")
|
||||
else()
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -Wall")
|
||||
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native")
|
||||
endif ()
|
||||
else ()
|
||||
endif()
|
||||
else()
|
||||
set(${CMAKE_CXX_FLAGS} "${CMAKE_CXX_FLAGS} -O3 -fPIC")
|
||||
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native")
|
||||
if (DEFINED ENV{QNX_HOST})
|
||||
list(APPEND LIBS socket dl)
|
||||
if(DEFINED ENV{QNX_HOST})
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ftemplate-depth-32")
|
||||
add_library(pip STATIC ${CPPS})
|
||||
else ()
|
||||
list(APPEND LIBS pthread dl util)
|
||||
if (NOT APPLE)
|
||||
list(APPEND LIBS rt)
|
||||
endif()
|
||||
else()
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
|
||||
add_library(pip SHARED ${CPPS})
|
||||
endif ()
|
||||
endif ()
|
||||
endif()
|
||||
endif()
|
||||
target_link_libraries(pip ${LIBS})
|
||||
|
||||
# Test program
|
||||
@@ -221,34 +242,34 @@ target_link_libraries(pip_test pip)# ${QT_QTCORE_LIBRARY})
|
||||
|
||||
# Install
|
||||
# Check if system or local install will be used (to system install use "-DLIB=" argument of cmake)
|
||||
if (LIB)
|
||||
if (WIN32)
|
||||
if (MINGW)
|
||||
if(LIB)
|
||||
if(WIN32)
|
||||
if(MINGW)
|
||||
find_package(MinGW REQUIRED)
|
||||
set(CMAKE_INSTALL_PREFIX ${MINGW_DIR})
|
||||
install(FILES ${HDRS} DESTINATION ${MINGW_INCLUDE}/pip)
|
||||
install(TARGETS pip DESTINATION ${MINGW_LIB})
|
||||
install(TARGETS pip DESTINATION ${MINGW_BIN})
|
||||
endif ()
|
||||
else ()
|
||||
if (APPLE)
|
||||
endif()
|
||||
else()
|
||||
if(APPLE)
|
||||
set(CMAKE_INSTALL_PREFIX /usr/local)
|
||||
else()
|
||||
set(CMAKE_INSTALL_PREFIX /usr)
|
||||
set(CMAKE_INSTALL_PREFIX /usr)
|
||||
endif()
|
||||
install(FILES ${HDRS} DESTINATION ${CMAKE_INSTALL_PREFIX}/include/pip)
|
||||
install(TARGETS pip DESTINATION ${CMAKE_INSTALL_PREFIX}/lib)
|
||||
endif ()
|
||||
endif()
|
||||
message(STATUS "Install to system \"${CMAKE_INSTALL_PREFIX}\"")
|
||||
# Precompiled header
|
||||
#add_custom_target(pip_pch ALL COMMAND ${CMAKE_CXX_COMPILER} -O2 -fPIC -g3 ${CMAKE_INSTALL_PREFIX}/include/pip/pip.h DEPENDS pip SOURCES ${HDRS})
|
||||
#list(APPEND HDRS "pip.h.gch")
|
||||
file(GLOB CMAKES "*.cmake")
|
||||
install(FILES ${CMAKES} DESTINATION ${CMAKE_ROOT}/Modules)
|
||||
else ()
|
||||
else()
|
||||
install(TARGETS pip DESTINATION bin)
|
||||
message(STATUS "Install to local \"bin\"")
|
||||
endif ()
|
||||
endif()
|
||||
|
||||
# Auxiliary
|
||||
add_subdirectory("src/auxiliary/piterminal")
|
||||
|
||||
Reference in New Issue
Block a user