git-svn-id: svn://db.shs.com.ru/pip@286 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5

This commit is contained in:
2016-11-30 12:35:35 +00:00
parent 17f118354d
commit d882cc1a69
3 changed files with 64 additions and 60 deletions

View File

@@ -219,7 +219,8 @@ if (LIB)
# 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")
install(FILES "FindPIP.cmake" DESTINATION ${CMAKE_ROOT}/Modules)
file(GLOB CMAKES "*.cmake")
install(FILES ${CMAKES} DESTINATION ${CMAKE_ROOT}/Modules)
else ()
install(TARGETS pip DESTINATION bin)
message(STATUS "Install to local \"bin\"")

View File

@@ -30,63 +30,5 @@ if (PIP_FIND_VERSION VERSION_GREATER PIP_VERSION)
message(FATAL_ERROR "PIP version ${PIP_VERSION} is available, but ${PIP_FIND_VERSION} requested!")
endif ()
macro (pip_code_model SRC RESULT)
set(RESULT "")
set(OPTS "")
set(_IS_OPT false)
foreach (_A ${ARGN})
#message(STATUS ${_A})
if (_IS_OPT)
list (APPEND OPTS ${_A})
else ()
if ("${_A}" STREQUAL "OPTIONS")
set(_IS_OPT true)
else ()
set (RESULT ${_A})
endif ()
endif ()
endforeach()
#message(STATUS "src = ${CMAKE_CURRENT_SOURCE_DIR}/${SRC}")
#message(STATUS "result = ${RESULT}")
#message(STATUS "options = ${OPTS}")
set(NEED_PARSE FALSE CACHE BOOL "NEED_PARSE" FORCE)
if (DEFINED CACHE_CMG_FILES)
string(REPLACE " " ";" CMG_LIST_C "${CACHE_CMG_FILES}")
foreach (CF ${CMG_LIST_C})
file (TIMESTAMP ${CF} ATIME)
if (NOT TIME_${CF} STREQUAL ATIME)
set(NEED_PARSE TRUE)
#message(STATUS "MOD cache")
endif ()
set(TIME_${CF} ${ATIME} CACHE INTERNAL TIME_${CF} FORCE)
#message (STATUS ${CF} ": " ${ATIME})
endforeach (CF)
else ()
set(NEED_PARSE TRUE)
#message(STATUS "NEW cache")
endif ()
set(${RESULT} ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}_ccm.cpp)
#message(STATUS "Res = ${${RESULT}}")
if (NOT EXISTS ${${RESULT}})
set(NEED_PARSE TRUE)
endif ()
if (NEED_PARSE)
message(STATUS "Creating code model based on \"${SRC}\", please wait ... ")
#message(STATUS "exec \"-qP ${OPTS} -o ${PROJECT_NAME}_ccm -I${PIP_INCLUDES} ${SRC}\"")
#message(STATUS "exec ${PIP_CMG} -P ${OPTS} -o ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}_ccm -I${PIP_INCLUDES} ${CMAKE_CURRENT_SOURCE_DIR}/${SRC}")
execute_process(OUTPUT_VARIABLE CMG_OUT COMMAND ${PIP_CMG} -qP ${OPTS} -o ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}_ccm -I${PIP_INCLUDES} ${CMAKE_CURRENT_SOURCE_DIR}/${SRC})
message(STATUS "Creating code model done, to use it include \"${PROJECT_NAME}_ccm.h\"")
string(REPLACE "\n" ";" CMG_LIST "${CMG_OUT}")
string(REPLACE "\n" " " CMG_LIST_S "${CMG_OUT}")
set(CACHE_CMG_FILES ${CMG_LIST_S} CACHE INTERNAL "CACHE_CMG_FILES" FORCE)
foreach (CF ${CMG_LIST})
file (TIMESTAMP ${CF} ATIME)
set(TIME_${CF} ${ATIME} CACHE INTERNAL TIME_${CF} FORCE)
endforeach (CF)
else ()
message(STATUS "Code model is up to date :-)")
endif ()
#message(STATUS ${CMG_OUT})
#message(STATUS ${CACHE_CMG_FILES})
endmacro (pip_code_model)
include(PIPMacros.cmake)

61
PIPMacros.cmake Normal file
View File

@@ -0,0 +1,61 @@
macro (pip_code_model SRC RESULT)
set(RESULT "")
set(OPTS "")
set(_IS_OPT false)
foreach (_A ${ARGN})
#message(STATUS ${_A})
if (_IS_OPT)
list (APPEND OPTS ${_A})
else ()
if ("${_A}" STREQUAL "OPTIONS")
set(_IS_OPT true)
else ()
set (RESULT ${_A})
endif ()
endif ()
endforeach()
#message(STATUS "src = ${CMAKE_CURRENT_SOURCE_DIR}/${SRC}")
#message(STATUS "result = ${RESULT}")
#message(STATUS "options = ${OPTS}")
set(NEED_PARSE FALSE CACHE BOOL "NEED_PARSE" FORCE)
if (DEFINED CACHE_CMG_FILES)
string(REPLACE " " ";" CMG_LIST_C "${CACHE_CMG_FILES}")
foreach (CF ${CMG_LIST_C})
file (TIMESTAMP ${CF} ATIME)
if (NOT TIME_${CF} STREQUAL ATIME)
set(NEED_PARSE TRUE)
#message(STATUS "MOD cache")
endif ()
set(TIME_${CF} ${ATIME} CACHE INTERNAL TIME_${CF} FORCE)
#message (STATUS ${CF} ": " ${ATIME})
endforeach (CF)
else ()
set(NEED_PARSE TRUE)
#message(STATUS "NEW cache")
endif ()
set(${RESULT} ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}_ccm.cpp)
#message(STATUS "Res = ${${RESULT}}")
if (NOT EXISTS ${${RESULT}})
set(NEED_PARSE TRUE)
endif ()
if (NEED_PARSE)
message(STATUS "Creating code model based on \"${SRC}\", please wait ... ")
#message(STATUS "exec \"-qP ${OPTS} -o ${PROJECT_NAME}_ccm -I${PIP_INCLUDES} ${SRC}\"")
#message(STATUS "exec ${PIP_CMG} -P ${OPTS} -o ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}_ccm -I${PIP_INCLUDES} ${CMAKE_CURRENT_SOURCE_DIR}/${SRC}")
execute_process(OUTPUT_VARIABLE CMG_OUT COMMAND ${PIP_CMG} -qP ${OPTS} -o ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}_ccm -I${PIP_INCLUDES} ${CMAKE_CURRENT_SOURCE_DIR}/${SRC})
message(STATUS "Creating code model done, to use it include \"${PROJECT_NAME}_ccm.h\"")
string(REPLACE "\n" ";" CMG_LIST "${CMG_OUT}")
string(REPLACE "\n" " " CMG_LIST_S "${CMG_OUT}")
set(CACHE_CMG_FILES ${CMG_LIST_S} CACHE INTERNAL "CACHE_CMG_FILES" FORCE)
foreach (CF ${CMG_LIST})
file (TIMESTAMP ${CF} ATIME)
set(TIME_${CF} ${ATIME} CACHE INTERNAL TIME_${CF} FORCE)
endforeach (CF)
else ()
message(STATUS "Code model is up to date :-)")
endif ()
#message(STATUS ${CMG_OUT})
#message(STATUS ${CACHE_CMG_FILES})
endmacro (pip_code_model)