git-svn-id: svn://db.shs.com.ru/pip@966 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5
This commit is contained in:
31
cmake/DownloadGTest.cmake
Normal file
31
cmake/DownloadGTest.cmake
Normal file
@@ -0,0 +1,31 @@
|
||||
# Download and unpack googletest at configure time
|
||||
configure_file(GTestCMakeLists.txt.in googletest-download/CMakeLists.txt)
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" .
|
||||
RESULT_VARIABLE result
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/googletest-download )
|
||||
if(result)
|
||||
message(FATAL_ERROR "CMake step for googletest failed: ${result}")
|
||||
endif()
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} --build .
|
||||
RESULT_VARIABLE result
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/googletest-download )
|
||||
if(result)
|
||||
message(FATAL_ERROR "Build step for googletest failed: ${result}")
|
||||
endif()
|
||||
|
||||
# Prevent overriding the parent project's compiler/linker
|
||||
# settings on Windows
|
||||
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
|
||||
|
||||
# Add googletest directly to our build. This defines
|
||||
# the gtest and gtest_main targets.
|
||||
add_subdirectory(${CMAKE_CURRENT_BINARY_DIR}/googletest-src
|
||||
${CMAKE_CURRENT_BINARY_DIR}/googletest-build
|
||||
EXCLUDE_FROM_ALL)
|
||||
|
||||
# The gtest/gtest_main targets carry header search path
|
||||
# dependencies automatically when using CMake 2.8.11 or
|
||||
# later. Otherwise we have to add them here ourselves.
|
||||
if (CMAKE_VERSION VERSION_LESS 2.8.11)
|
||||
include_directories("${gtest_SOURCE_DIR}/include")
|
||||
endif()
|
||||
25
cmake/FindMinGW.cmake
Normal file
25
cmake/FindMinGW.cmake
Normal file
@@ -0,0 +1,25 @@
|
||||
if(${MINGW})
|
||||
if(NOT DEFINED MINGW_DIR)
|
||||
get_filename_component(MINGW_BIN ${CMAKE_CXX_COMPILER} PATH)
|
||||
get_filename_component(MINGW_DIR ${MINGW_BIN} PATH)
|
||||
find_path(MINGW_INCLUDE
|
||||
windows.h
|
||||
PATHS
|
||||
ENV INCLUDE
|
||||
${MINGW_DIR}
|
||||
${MINGW_DIR}/i686-w64-mingw32
|
||||
${MINGW_DIR}/x86_64-w64-mingw32
|
||||
PATH_SUFFIXES
|
||||
include)
|
||||
#message(STATUS "Find MinGW = ${MINGW_INCLUDE}")
|
||||
#if(NOT ${MINGW_INCLUDE}) MINGW_INCLUDE = ${MINGW_DIR}/include
|
||||
find_library(MINGW_LIB m HINTS ${MINGW_BIN}/../lib ${MINGW_INCLUDE}/../lib)
|
||||
get_filename_component(MINGW_LIB ${MINGW_LIB} PATH)
|
||||
if (NOT _MGW_MSG)
|
||||
set(_MGW_MSG 1 CACHE BOOL "msg_mingw" FORCE)
|
||||
message(STATUS "Found MinGW binary path = ${MINGW_BIN}")
|
||||
message(STATUS "Found MinGW include path = ${MINGW_INCLUDE}")
|
||||
message(STATUS "Found MinGW library path = ${MINGW_LIB}")
|
||||
endif()
|
||||
endif()
|
||||
endif(${MINGW})
|
||||
84
cmake/FindPIP.cmake
Normal file
84
cmake/FindPIP.cmake
Normal file
@@ -0,0 +1,84 @@
|
||||
#set(_PIP_MODULES pip pip_usb pip_crypt pip_fftw)
|
||||
if(WIN32)
|
||||
find_package(MinGW REQUIRED)
|
||||
endif()
|
||||
|
||||
set(_PIP_INCDIR "${PIP_DIR}/include/pip")
|
||||
set(_PIP_LIBDIR "${PIP_DIR}/lib")
|
||||
set(_PIP_BINDIR)
|
||||
set(_PIP_FP_DP)
|
||||
|
||||
if(MINGW_INCLUDE)
|
||||
list(APPEND _PIP_INCDIR "${MINGW_INCLUDE}/pip")
|
||||
list(APPEND _PIP_LIBDIR "${MINGW_LIB}")
|
||||
endif()
|
||||
if(CMAKE_CROSSCOMPILING)
|
||||
list(APPEND _PIP_INCDIR "${CMAKE_PREFIX_PATH}/include/pip")
|
||||
list(APPEND _PIP_LIBDIR "${CMAKE_PREFIX_PATH}/lib")
|
||||
else()
|
||||
if(NOT WIN32)
|
||||
list(APPEND _PIP_INCDIR "/usr/include/pip" "/usr/local/include/pip")
|
||||
list(APPEND _PIP_LIBDIR "/usr/lib" "/usr/local/lib")
|
||||
endif()
|
||||
if(APPLE)
|
||||
include_directories(/usr/local/include)
|
||||
link_directories(/usr/local/lib)
|
||||
endif()
|
||||
endif()
|
||||
list(APPEND _PIP_LIBDIR "$ENV{SMSDK_DIR}/lib")
|
||||
|
||||
if(MINGW_INCLUDE)
|
||||
list(APPEND _PIP_BINDIR "${MINGW_BIN}")
|
||||
endif()
|
||||
if(CMAKE_CROSSCOMPILING)
|
||||
set(_PIP_FP_DP "NO_DEFAULT_PATH")
|
||||
list(APPEND _PIP_BINDIR "/usr/bin" "/usr/local/bin")
|
||||
else()
|
||||
list(APPEND _PIP_BINDIR "${CMAKE_PREFIX_PATH}/bin")
|
||||
endif()
|
||||
list(APPEND _PIP_BINDIR "${PIP_DIR}/bin")
|
||||
|
||||
find_library(PIP_LIBRARY pip HINTS ${_PIP_LIBDIR})
|
||||
find_library(PIP_USB_LIBRARY pip_usb HINTS ${_PIP_LIBDIR})
|
||||
find_library(PIP_CRYPT_LIBRARY pip_crypt HINTS ${_PIP_LIBDIR})
|
||||
find_library(PIP_FFTW_LIBRARY pip_fftw HINTS ${_PIP_LIBDIR})
|
||||
find_library(PIP_COMPRESS_LIBRARY pip_compress HINTS ${_PIP_LIBDIR})
|
||||
find_library(PIP_IO_UTILS_LIBRARY pip_io_utils HINTS ${_PIP_LIBDIR})
|
||||
find_library(PIP_CONCURRENT_LIBRARY pip_concurrent HINTS ${_PIP_LIBDIR})
|
||||
find_library(PIP_CLOUD_LIBRARY pip_cloud HINTS ${_PIP_LIBDIR})
|
||||
find_file(PIP_H_INCLUDE "pip.h" HINTS ${_PIP_INCDIR} $ENV{SMSDK_DIR}/include/pip)
|
||||
if (DEFINED ANDROID_PLATFORM)
|
||||
set(PIP_INCLUDES ${ANDROID_SYSTEM_LIBRARY_PATH}/usr/include/pip)
|
||||
else()
|
||||
get_filename_component(PIP_INCLUDES ${PIP_H_INCLUDE} PATH)
|
||||
endif()
|
||||
find_program(PIP_CMG pip_cmg HINTS ${_PIP_BINDIR} ${_PIP_FP_DP})
|
||||
find_program(PIP_RC pip_rc HINTS ${_PIP_BINDIR} ${_PIP_FP_DP})
|
||||
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
|
||||
find_library(DL_LIBRARY dl)
|
||||
list(APPEND PIP_LIBRARY ${DL_LIBRARY})
|
||||
if (NOT DEFINED ANDROID_PLATFORM)
|
||||
find_library(PTHREAD_LIBRARY pthread)
|
||||
find_library(UTIL_LIBRARY util)
|
||||
list(APPEND PIP_LIBRARY ${PTHREAD_LIBRARY} ${UTIL_LIBRARY})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(NOT PIP_VERSION)
|
||||
file(STRINGS "${PIP_INCLUDES}/pip_version_str.h" _VERSION REGEX "\".*\"")
|
||||
string(REGEX MATCH "\".*\"" _VERSION ${_VERSION})
|
||||
string(LENGTH ${_VERSION} SL)
|
||||
math(EXPR SL ${SL}-2)
|
||||
string(SUBSTRING ${_VERSION} 1 ${SL} _VERSION)
|
||||
set(PIP_VERSION ${_VERSION} CACHE STRING "VERSION")
|
||||
if (NOT _PIP_MSG)
|
||||
set(_PIP_MSG 1 CACHE BOOL "msg_pip" FORCE)
|
||||
message(STATUS "Found PIP version ${PIP_VERSION} (${PIP_LIBRARY})")
|
||||
endif()
|
||||
endif()
|
||||
if(PIP_FIND_VERSION VERSION_GREATER PIP_VERSION)
|
||||
message(FATAL_ERROR "PIP version ${PIP_VERSION} is available, but ${PIP_FIND_VERSION} requested!")
|
||||
endif()
|
||||
|
||||
include(PIPMacros)
|
||||
|
||||
31
cmake/PIPDocumentation.cmake
Normal file
31
cmake/PIPDocumentation.cmake
Normal file
@@ -0,0 +1,31 @@
|
||||
macro(CONFIGURE_DOXYGEN_FILE DOXYGEN_CONFIG_FILE FILE_NAME_SUFFIX)
|
||||
if(EXISTS ${PROJECT_SOURCE_DIR}/${DOXYGEN_CONFIG_FILE})
|
||||
file(REMOVE "${CMAKE_CURRENT_BINARY_DIR}/doxyfile-${FILE_NAME_SUFFIX}")
|
||||
file(READ ${PROJECT_SOURCE_DIR}/${DOXYGEN_CONFIG_FILE} DOXYFILE_CONTENTS)
|
||||
string(REPLACE "\\\n" " " DOXYFILE_CONTENTS "${DOXYFILE_CONTENTS}")
|
||||
string(REPLACE "\n" ";" DOXYFILE_LINES "${DOXYFILE_CONTENTS}")
|
||||
foreach(LINE IN LISTS DOXYFILE_LINES)
|
||||
if(LINE STRGREATER "")
|
||||
string(REGEX MATCH "^[a-zA-Z]([^ ])+" DOXY_PARAM ${LINE})
|
||||
if(DEFINED DOXY_${DOXY_PARAM})
|
||||
STRING(REGEX REPLACE "=([^\n])+" "= ${DOXY_${DOXY_PARAM}}" LINE ${LINE})
|
||||
endif(DEFINED DOXY_${DOXY_PARAM})
|
||||
endif()
|
||||
file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/doxyfile-${FILE_NAME_SUFFIX} "${LINE}\n")
|
||||
endforeach()
|
||||
else()
|
||||
MESSAGE(SEND_ERROR "Doxygen configuration file '${DOXYGEN_CONFIG_FILE}' not found, can`t generate documentation")
|
||||
endif()
|
||||
endmacro(CONFIGURE_DOXYGEN_FILE)
|
||||
|
||||
|
||||
macro(ADD_DOCUMENTATION TARGET DOXYGEN_CONFIG_FILE)
|
||||
if(DOXYGEN_FOUND)
|
||||
configure_doxygen_file(${DOXYGEN_CONFIG_FILE} ${TARGET})
|
||||
add_custom_target("genereate.${TARGET}" COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/doxyfile-${TARGET})
|
||||
add_custom_target("${TARGET}" COMMAND ${CMAKE_COMMAND} -D COMPONENT=doc -P cmake_install.cmake)
|
||||
add_dependencies("${TARGET}" "genereate.${TARGET}")
|
||||
else(DOXYGEN_FOUND)
|
||||
message(STATUS "Doxygen not found, can`t generate documentation")
|
||||
endif(DOXYGEN_FOUND)
|
||||
endmacro(ADD_DOCUMENTATION)
|
||||
111
cmake/PIPMacros.cmake
Normal file
111
cmake/PIPMacros.cmake
Normal file
@@ -0,0 +1,111 @@
|
||||
macro(PIP_EXTRACT_OPTIONS _pip_files _pip_options _abs)
|
||||
set(${_pip_files})
|
||||
set(${_pip_options})
|
||||
set(_PIP_DOING_OPTIONS FALSE)
|
||||
foreach(_currentArg ${ARGN})
|
||||
if("x${_currentArg}" STREQUAL "xABSOLUTE")
|
||||
set(${_abs} TRUE)
|
||||
else()
|
||||
if("x${_currentArg}" STREQUAL "xOPTIONS")
|
||||
set(_PIP_DOING_OPTIONS TRUE)
|
||||
else()
|
||||
if(_PIP_DOING_OPTIONS)
|
||||
list(APPEND ${_pip_options} "${_currentArg}")
|
||||
else()
|
||||
list(APPEND ${_pip_files} "${_currentArg}")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
endforeach()
|
||||
endmacro()
|
||||
|
||||
|
||||
# usage: pip_code_model(<out_var> file0 [file1 ...] [OPTIONS opt0 [opt1 ...]] [ABSOLUTE])
|
||||
# options you can see by exec "pip_cmg -h"
|
||||
# if not ABSOLUTE source files will be prepended by CMAKE_CURRENT_SOURCE_DIR
|
||||
# add ${<out_var>} to your target
|
||||
macro(pip_code_model RESULT)
|
||||
PIP_EXTRACT_OPTIONS(CCM_SRC OPTS ABS ${ARGN})
|
||||
#message(STATUS "src = ${CCM_SRC}")
|
||||
#message(STATUS "result = ${RESULT}")
|
||||
#message(STATUS "options = \"${CCM_OPTS}\"")
|
||||
set(CMG_INCLUDES)
|
||||
foreach(pi ${PIP_INCLUDES})
|
||||
list(APPEND CMG_INCLUDES "-I${pi}")
|
||||
endforeach()
|
||||
set(CCM_OUT ${CMAKE_CURRENT_BINARY_DIR}/ccm_${PROJECT_NAME}.cpp)
|
||||
set(${RESULT} ${${RESULT}} ${CCM_OUT})
|
||||
set(CCM_FILES)
|
||||
if (ABS)
|
||||
foreach(csrc ${CCM_SRC})
|
||||
list(APPEND CCM_FILES "${csrc}")
|
||||
endforeach()
|
||||
else()
|
||||
foreach(csrc ${CCM_SRC})
|
||||
list(APPEND CCM_FILES "${CMAKE_CURRENT_SOURCE_DIR}/${csrc}")
|
||||
endforeach()
|
||||
endif()
|
||||
#message(STATUS "CCM = ${RESULT}")
|
||||
if(NOT DEFINED PIP_DLL_DIR)
|
||||
set(PIP_DLL_DIR ${CMAKE_CURRENT_BINARY_DIR})
|
||||
endif()
|
||||
add_custom_command(OUTPUT ${CCM_OUT}
|
||||
COMMAND ${PIP_CMG}
|
||||
ARGS -q ${OPTS} -o ${CMAKE_CURRENT_BINARY_DIR}/ccm_${PROJECT_NAME} ${CMG_INCLUDES} ${CCM_FILES}
|
||||
DEPENDS ${CCM_SRC}
|
||||
WORKING_DIRECTORY ${PIP_DLL_DIR}
|
||||
COMMENT "Generating ccm_${PROJECT_NAME}.h, ccm_${PROJECT_NAME}.cpp"
|
||||
VERBATIM)
|
||||
endmacro()
|
||||
|
||||
|
||||
# usage: pip_resources(<out_var> file)
|
||||
# add ${<out_var>} to your target
|
||||
macro(pip_resources RESULT INPUT)
|
||||
#message(STATUS "src = ${CCM_SRC}")
|
||||
#message(STATUS "result = ${RESULT}")
|
||||
#message(STATUS "options = \"${CCM_OPTS}\"")
|
||||
get_filename_component(RC_OUT "${INPUT}" NAME_WE)
|
||||
set(RC_FILE "pirc_${RC_OUT}.cpp")
|
||||
set(SRC_RC_OUT "${RC_OUT}")
|
||||
set(RC_OUT ${CMAKE_CURRENT_BINARY_DIR}/${RC_FILE})
|
||||
set(${RESULT} ${${RESULT}} ${RC_OUT})
|
||||
set(CCM_FILES)
|
||||
#if (ABS)
|
||||
if(IS_ABSOLUTE "${INPUT}")
|
||||
set(RC_FILES "${INPUT}")
|
||||
else()
|
||||
set(RC_FILES "${CMAKE_CURRENT_SOURCE_DIR}/${INPUT}")
|
||||
endif()
|
||||
#else()
|
||||
# foreach(csrc ${CCM_SRC})
|
||||
# list(APPEND CCM_FILES "${CMAKE_CURRENT_SOURCE_DIR}/${csrc}")
|
||||
# endforeach()
|
||||
#endif()
|
||||
#message(STATUS "CCM = ${RESULT}")
|
||||
if(NOT DEFINED PIP_DLL_DIR)
|
||||
set(PIP_DLL_DIR ${CMAKE_CURRENT_BINARY_DIR})
|
||||
endif()
|
||||
set(RC_DEPS ${RC_FILES})
|
||||
if(NOT PIP_BUILD)
|
||||
execute_process(COMMAND "${PIP_RC}" -l -i "${RC_FILES}"
|
||||
WORKING_DIRECTORY ${PIP_DLL_DIR}
|
||||
OUTPUT_VARIABLE RC_LIST)
|
||||
#message("${RC_LIST}")
|
||||
string(REPLACE "\n" ";" RC_LIST "${RC_LIST}")
|
||||
list(APPEND RC_DEPS "${RC_LIST}")
|
||||
endif()
|
||||
#message("PIP_RC: ${PIP_RC}")
|
||||
#message("RC_OUT: ${RC_OUT}")
|
||||
#message("RC_FILES: ${RC_FILES}")
|
||||
#message("PIP_DLL_DIR: ${PIP_DLL_DIR}")
|
||||
#message("RC_DEPS: ${RC_DEPS}")
|
||||
add_custom_command(OUTPUT ${RC_OUT}
|
||||
COMMAND ${PIP_RC}
|
||||
ARGS -s -i ${RC_FILES} -o ${RC_OUT} -n ${SRC_RC_OUT}
|
||||
DEPENDS ${RC_DEPS}
|
||||
WORKING_DIRECTORY ${PIP_DLL_DIR}
|
||||
COMMENT "Generating ${RC_FILE}"
|
||||
VERBATIM)
|
||||
endmacro()
|
||||
|
||||
Reference in New Issue
Block a user