356 lines
11 KiB
CMake
356 lines
11 KiB
CMake
PROJECT(ponyprog)
|
|
|
|
# Configure CMake ...
|
|
CMAKE_MINIMUM_REQUIRED(VERSION 2.8 FATAL_ERROR)
|
|
CMAKE_POLICY(SET CMP0003 OLD)
|
|
CMAKE_POLICY(SET CMP0015 OLD)
|
|
|
|
# set the Qt version to 4 or 5
|
|
SET(USE_QT_VERSION 4)
|
|
|
|
# # SET(FILES_TO_TRANSLATE)
|
|
|
|
|
|
|
|
#disable -rdynamic
|
|
# SET(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "")
|
|
# SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "")
|
|
|
|
|
|
# FILE (GLOB TRANSLATIONS_FILES ${CMAKE_CURRENT_SOURCE_DIR}/translations/*.ts)
|
|
|
|
# OPTION (UPDATE_TRANSLATIONS "Update source translation ${CMAKE_CURRENT_SOURCE_DIR}/translations/*.ts" OFF)
|
|
|
|
|
|
MESSAGE(STATUS "Qt version for compiling: " ${USE_QT_VERSION})
|
|
|
|
IF(NOT ${USE_QT_VERSION} MATCHES "4" AND NOT ${USE_QT_VERSION} MATCHES "5")
|
|
MESSAGE(FATAL_ERROR "-- Qt version must be set to 4 or 5!")
|
|
ENDIF()
|
|
|
|
#debug or release
|
|
|
|
OPTION (USE_DEBUGGER "Include in binary file debug information" OFF)
|
|
SET(USE_DEBUGGER false)
|
|
|
|
#enable or disable profiling info
|
|
# SET(USE_PROFILER false)
|
|
|
|
OPTION (USE_PROFILER "Include in binary file profiling information" OFF)
|
|
|
|
|
|
|
|
IF(${USE_DEBUGGER})
|
|
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS_DEBUG} -Wall")
|
|
ELSE()
|
|
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS_RELEASE} -Wall")
|
|
ENDIF()
|
|
|
|
MESSAGE(STATUS "CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}")
|
|
|
|
INCLUDE(CheckIncludeFile)
|
|
INCLUDE(CheckIncludeFileCXX)
|
|
INCLUDE(TestCXXAcceptsFlag)
|
|
INCLUDE(CheckCXXCompilerFlag)
|
|
INCLUDE(FindPkgConfig)
|
|
|
|
|
|
SET(TARGET_NAME ponyprog )
|
|
SET(CMAKE_HELPERS_BINARY_DIR ${PROJECT_SOURCE_DIR}/cmake)
|
|
SET(CMAKE_HELPERS_SOURCE_DIR ${PROJECT_SOURCE_DIR}/cmake)
|
|
LIST(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
|
|
|
|
SET(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
|
|
|
|
|
|
|
|
# INCLUDE(PONYPROGOutOfSourceBuild) # Disallow in-source builds
|
|
INCLUDE(GenerateDEF) # Convenience macro for linking Win32 DLLs using MSVC
|
|
INCLUDE(Dependencies)
|
|
INCLUDE(WordSize) # Detect 32/64 bit platform
|
|
INCLUDE(Compiler) # Detect problematic compilers
|
|
|
|
|
|
SET(QtApp_RCCS "${CMAKE_CURRENT_SOURCE_DIR}/ponyprog.qrc")
|
|
|
|
SET(CURRENT_BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR})
|
|
|
|
|
|
# Set the PonyProg version
|
|
# this for generating of version file from README file
|
|
# the idea is to descript all changes in this file, the ne changes are in the top of file
|
|
# see the patched README file in this commit
|
|
#cat README | grep -E '^[0-9]+\.[0-9]+\.[0-9]+' | head -n 1
|
|
EXECUTE_PROCESS (
|
|
COMMAND cat HISTORY
|
|
COMMAND grep -E "^[0-9]+\\.[0-9]+\\.[0-9]+"
|
|
COMMAND head -n 1
|
|
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
|
|
RESULT_VARIABLE APP_VERSION
|
|
OUTPUT_VARIABLE DESCRIBE_STRING
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
|
|
|
|
|
IF(NOT DESCRIBE_STRING)
|
|
SET(DESCRIBE_STRING "no valid git tag for ${PROJECT_NAME} found")
|
|
ELSE()
|
|
STRING(REGEX MATCH "([0-9]+\\.[0-9]+\\.[0-9]+)" APP_VERSION "${DESCRIBE_STRING}" )
|
|
IF (NOT APP_VERSION)
|
|
SET(DESCRIBE_STRING "no valid git tag ${PROJECT_NAME}-x.x.x found")
|
|
ENDIF()
|
|
ENDIF()
|
|
|
|
MESSAGE(STATUS "Version info: ${APP_VERSION}")
|
|
SET(VERSION ${APP_VERSION})
|
|
|
|
#
|
|
SET(APP_VERSION "3.0.0")
|
|
SET(APP_AUTHOR "Claudio Lanconelli")
|
|
SET(APP_EMAIL "PonyProg2000@gmail.com")
|
|
SET(APP_NAME "PonyProg")
|
|
|
|
EXECUTE_PROCESS (
|
|
COMMAND date +"%d.%m.%Y"
|
|
COMMAND sed -e "s/\"//g"
|
|
OUTPUT_VARIABLE APP_BUILD_DATE
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
|
|
|
MESSAGE(STATUS "Version build date: ${APP_BUILD_DATE}")
|
|
|
|
#
|
|
SET(PONYPROG_PACKAGE ponyprog)
|
|
SET(PONYPROG_HOST ${CMAKE_SYSTEM} ${CMAKE_SYSTEM_PROCESSOR})
|
|
SET(PONYPROG_COPYRIGHT "Copyright (c) 1997-2017 Claudio Lanconelli , All Rights Reserved.")
|
|
SET(PONYPROG_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX})
|
|
|
|
# Setup high-level build options
|
|
# IF(MSVC)
|
|
# SET(PONYPROG_ENABLE_SYMBOL_VISIBILITY_DEFAULT ON)
|
|
# ELSE(MSVC)
|
|
# SET(PONYPROG_ENABLE_SYMBOL_VISIBILITY_DEFAULT OFF)
|
|
# ENDIF(MSVC)
|
|
|
|
|
|
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fno-exceptions -fno-rtti")
|
|
|
|
# options for gprof
|
|
IF(${USE_PROFILER})
|
|
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pg")
|
|
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pg")
|
|
SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -pg")
|
|
# after execution of program: gprof ./build/ponyprog
|
|
# and get the information from gprof.txt file
|
|
MESSAGE(STATUS "Compile with profiling information")
|
|
ELSE()
|
|
MESSAGE(STATUS "Compile without profiling information")
|
|
ENDIF()
|
|
|
|
|
|
|
|
IF(${USE_QT_VERSION} MATCHES "4")
|
|
SET(HAVE_QT_PRINTSUPPORT true)
|
|
FIND_PACKAGE(Qt4 COMPONENTS QtCore QtGui REQUIRED)
|
|
|
|
IF(NOT QT4_FOUND)
|
|
MESSAGE(FATAL_ERROR "Qt4 could not be found. "
|
|
"If it's INSTALLed in a non-standard location, specify the path to qmake in QT_QMAKE_EXECUTABLE. "
|
|
"You can do it in interactive mode (ccmake instead of cmake) or using -DVAR=VAL syntax.")
|
|
ENDIF()
|
|
ELSE()
|
|
FIND_PACKAGE(Qt5 COMPONENTS Core PrintSupport Gui Widgets Multimedia REQUIRED QUIET)
|
|
|
|
# FIND_PACKAGE(Qt5 COMPONENTS LinguistTools REQUIRED QUIET)
|
|
|
|
IF(NOT Qt5Widgets_FOUND)
|
|
MESSAGE(FATAL_ERROR "Qt5 could not be found. "
|
|
"If it's INSTALLed in a non-standard location, specify the path to qmake in QT_QMAKE_EXECUTABLE. "
|
|
"You can do it in interactive mode (ccmake instead of cmake) or using -DVAR=VAL syntax.")
|
|
ENDIF(NOT Qt5Widgets_FOUND)
|
|
ENDIF()
|
|
|
|
|
|
IF(${USE_QT_VERSION} MATCHES "4")
|
|
INCLUDE_DIRECTORIES(${QT_INCLUDES})
|
|
MESSAGE(STATUS "QT_INCLUDES ${QT_INCLUDES}")
|
|
# LINK_DIRECTORIES(${QT_LIBRARY_DIR})
|
|
ELSE()
|
|
INCLUDE_DIRECTORIES(${QT_INCLUDES} ${Qt5Widgets_INCLUDE_DIRS} ${Qt5PrintSupport_INCLUDE_DIRS} ${Qt5Multimedia_INCLUDE_DIRS})
|
|
|
|
MESSAGE(STATUS "QT_INCLUDES ${QT_INCLUDES} ${Qt5Widgets_INCLUDE_DIRS} ${Qt5Multimedia_INCLUDE_DIRS}")
|
|
|
|
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Widgets_EXECUTABLE_COMPILE_FLAGS} ${Qt5Multimedia_EXECUTABLE_COMPILE_FLAGS} ${Qt5PrintSupport_EXECUTABLE_COMPILE_FLAGS}")
|
|
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -lQt5PrintSupport")
|
|
ENDIF()
|
|
|
|
|
|
configure_file (
|
|
"${PROJECT_SOURCE_DIR}/SrcPony/version-cmake.h.in"
|
|
"${PROJECT_SOURCE_DIR}/SrcPony/version.h" )
|
|
|
|
|
|
SET ( OBJECTS_DIR temp )
|
|
SET ( MOC_DIR temp )
|
|
SET ( UI_HEADERS_DIR temp )
|
|
SET ( UI_SOURCES_DIR temp )
|
|
|
|
ADD_SUBDIRECTORY(qhexedit2/src)
|
|
ADD_SUBDIRECTORY(SrcPony)
|
|
|
|
INCLUDE_DIRECTORIES( ${CMAKE_SOURCE_DIR} $(CMAKE_CURRENT_SOURCE_DIR)/qhexedit2/src/ $(CMAKE_CURRENT_SOURCE_DIR)/SrcPony/ )
|
|
|
|
|
|
IF(${USE_QT_VERSION} MATCHES "4")
|
|
# QT4_ADD_TRANSLATION(APP_TRANSLATIONS ${TRANSLATION})
|
|
QT4_WRAP_CPP(APP_HEADERS_MOC ${HEX_HEADERS} ${PONY_HEADERS} )
|
|
QT4_WRAP_UI(APP_FORMS_HEADERS ${PONY_FORMS} )
|
|
QT4_ADD_RESOURCES(APP_RESOURCES_RCC ${APP_RESOURCES})
|
|
ELSE()
|
|
# QT5_ADD_TRANSLATION(APP_TRANSLATIONS ${TRANSLATION})
|
|
QT5_WRAP_CPP(APP_HEADERS_MOC ${HEX_HEADERS} ${PONY_HEADERS} )
|
|
QT5_WRAP_UI(APP_FORMS_HEADERS ${PONY_FORMS} )
|
|
QT5_ADD_RESOURCES(APP_RESOURCES_RCC ${APP_RESOURCES})
|
|
ENDIF()
|
|
|
|
|
|
MESSAGE(STATUS "PONY_RESOURCES ${APP_RESOURCES_RCC}")
|
|
|
|
INCLUDE_DIRECTORIES( ${CMAKE_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
|
|
|
|
SOURCE_GROUP( "Generated Files" FILES
|
|
${MOC_FILES_CPP}
|
|
${APP_FORMS_HEADERS}
|
|
${APP_RESOURCES_RCC}
|
|
)
|
|
|
|
|
|
IF(NOT ${USE_DEBUGGER})
|
|
ADD_DEFINITIONS(${QT_DEFINITIONS} -DQT_NO_DEBUG_OUTPUT -DQT_USE_FAST_CONCATENATION -DQT_USE_FAST_OPERATOR_PLUS)
|
|
ENDIF()
|
|
|
|
IF(${USE_QT_VERSION} MATCHES "4")
|
|
INCLUDE(${QT_USE_FILE})
|
|
ADD_DEFINITIONS(${QT_DEFINITIONS} -DNO_QT3SUPPORT -DDISABLE_QT3SUPPORT -DQT_PROJECT)
|
|
ELSE()
|
|
ADD_DEFINITIONS( ${Qt5Widgets_DEFINITIONS} ${Qt5PrintSupport_DEFINITIONS} ${Qt5Multimedia_DEFINITIONS} -DQT_PROJECT )
|
|
ENDIF()
|
|
|
|
ADD_EXECUTABLE(${CMAKE_PROJECT_NAME}
|
|
${APP_SOURCES}
|
|
${HEX_SOURCES}
|
|
${PONY_SOURCES}
|
|
${APP_HEADERS_MOC}
|
|
${APP_FORMS_HEADERS}
|
|
# ${APP_TRANSLATIONS}
|
|
${APP_RESOURCES_RCC}
|
|
)
|
|
|
|
|
|
IF(${USE_QT_VERSION} MATCHES "4")
|
|
TARGET_LINK_LIBRARIES(${CMAKE_PROJECT_NAME} ${QT_LIBRARIES} )
|
|
ELSE()
|
|
TARGET_LINK_LIBRARIES(${CMAKE_PROJECT_NAME} ${QT_LIBRARIES} ${Qt5Widgets_LIBRARIES} ${Qt5Multimedia_LIBRARIES} ${Qt5PrintSupport_LIBRARIES} )
|
|
MESSAGE(STATUS "QT LIBRARIES: ${QT_LIBRARIES} ${Qt5Widgets_LIBRARIES} ${Qt5Multimedia_LIBRARIES} ${Qt5PrintSupport_LIBRARIES} ${Qt5Core_LIBRARIES}")
|
|
ENDIF()
|
|
|
|
ADD_CUSTOM_TARGET (tags
|
|
COMMAND ctags -R -f tags ${CMAKE_SOURCE_DIR}/SrcPony
|
|
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
|
)
|
|
# MESSAGE("CMAKE_SOURCE_DIR main ${CMAKE_SOURCE_DIR}")
|
|
# MESSAGE("CMAKE_CURRENT_BINARY_DIR main ${CMAKE_CURRENT_BINARY_DIR}")
|
|
# INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR})
|
|
|
|
|
|
# Setup module enabled/disabled defaults ...
|
|
IF(MSVC)
|
|
SET(PONYPROG_BUILD_GLX_MODULE_DEFAULT ON)
|
|
SET(PONYPROG_BUILD_OSX_MODULE_DEFAULT OFF)
|
|
SET(PONYPROG_BUILD_VIRTUAL_OFFSCREEN_MODULE_DEFAULT OFF)
|
|
ENDIF(MSVC)
|
|
|
|
IF(UNIX AND NOT APPLE)
|
|
SET(PONYPROG_BUILD_GLX_MODULE_DEFAULT ON)
|
|
SET(PONYPROG_BUILD_OSX_MODULE_DEFAULT OFF)
|
|
SET(PONYPROG_BUILD_VIRTUAL_OFFSCREEN_MODULE_DEFAULT OFF)
|
|
ENDIF(UNIX AND NOT APPLE)
|
|
|
|
IF(APPLE)
|
|
SET(PONYPROG_BUILD_GLX_MODULE_DEFAULT ON)
|
|
SET(PONYPROG_BUILD_OSX_MODULE_DEFAULT ON)
|
|
SET(PONYPROG_BUILD_VIRTUAL_OFFSCREEN_MODULE_DEFAULT OFF)
|
|
ENDIF(APPLE)
|
|
|
|
|
|
OPTION(PONYPROG_ENABLE_SYMBOL_VISIBILITY "Minimize the number of symbols exported from shared libraries." ${PONYPROG_ENABLE_SYMBOL_VISIBILITY_DEFAULT})
|
|
MARK_AS_ADVANCED(PONYPROG_ENABLE_SYMBOL_VISIBILITY)
|
|
|
|
# OPTION(PONYPROG_ENABLE_TESTING "Build the Ponyprog regression test suite." OFF)
|
|
# SET(BUILD_TESTING ${PONYPROG_ENABLE_TESTING} CACHE INTERNAL "" FORCE)
|
|
# INCLUDE(CTest)
|
|
# MARK_AS_ADVANCED(DART_TESTING_TIMEOUT)
|
|
# IF(PONYPROG_ENABLE_TESTING)
|
|
# CMAKE_MINIMUM_REQUIRED(VERSION 2.6.1 FATAL_ERROR)
|
|
# CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/CTestCustom.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/CTestCustom.cmake @ONLY)
|
|
# ENDIF(PONYPROG_ENABLE_TESTING)
|
|
|
|
# Capture system configuration
|
|
INCLUDE(SystemConfiguration)
|
|
|
|
# MSVC configuration
|
|
IF(MSVC)
|
|
IF(NOT MSVC)
|
|
SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--enable-runtime-pseudo-reloc" CACHE STRING "" FORCE)
|
|
SET(CMAKE_SHARED_LINKER_FLAGS "-Wl,--enable-runtime-pseudo-reloc -Wl,--export-all-symbols" CACHE STRING "" FORCE)
|
|
ENDIF(NOT MSVC)
|
|
ENDIF(MSVC)
|
|
|
|
# Setup output directories ...
|
|
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PONYPROG_BINARY_DIR}/bin)
|
|
|
|
|
|
IF(MSVC)
|
|
SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PONYPROG_BINARY_DIR}/bin)
|
|
ELSE(MSVC)
|
|
SET(PONYPROG_LIBDIR lib) # Allows us to handle 64-bit libs if/when it becomes necessary.
|
|
SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PONYPROG_BINARY_DIR}/${PONYPROG_LIBDIR})
|
|
ENDIF(MSVC)
|
|
|
|
# Setup a macro for compiling resources ...
|
|
MACRO(PONYPROG_COMPILE_RESOURCE OUTPUT INPUT RESOURCE_PATH)
|
|
|
|
SET(INPUT_FILE "${CMAKE_CURRENT_SOURCE_DIR}/${INPUT}")
|
|
SET(OUTPUT_FILE "${CMAKE_CURRENT_BINARY_DIR}/${INPUT}.cpp")
|
|
GET_FILENAME_COMPONENT(OUTPUT_PATH ${OUTPUT_FILE} PATH)
|
|
|
|
GET_TARGET_PROPERTY(PONYPROG_RESOURCE_COMPILER ponyprog-resource-compiler LOCATION)
|
|
|
|
ADD_CUSTOM_COMMAND(
|
|
DEPENDS ponyprog-resource-compiler
|
|
DEPENDS ${INPUT_FILE}
|
|
COMMAND ${CMAKE_COMMAND} -E make_directory ${OUTPUT_PATH}
|
|
COMMAND ${PONYPROG_RESOURCE_COMPILER} --input ${INPUT_FILE} --path \"<path>${RESOURCE_PATH}</path>\" --output ${OUTPUT_FILE}
|
|
OUTPUT ${OUTPUT_FILE}
|
|
COMMENT "Compiling resource ${INPUT_FILE}"
|
|
)
|
|
|
|
LIST(APPEND ${OUTPUT} ${OUTPUT_FILE})
|
|
|
|
ENDMACRO(PONYPROG_COMPILE_RESOURCE)
|
|
|
|
# Setup subdirectories ...
|
|
PONYPROG_CONDITIONAL_BUILD(MSVC gendef)
|
|
#
|
|
OPTION(PONYPROG_ENABLE_DISTRIBUTION "Enable distribution targets." ON)
|
|
PONYPROG_CONDITIONAL_BUILD(PONYPROG_ENABLE_DISTRIBUTION distribution)
|
|
|
|
# Hide some cruft ...
|
|
MARK_AS_ADVANCED(CMAKE_BACKWARDS_COMPATIBILITY)
|
|
MARK_AS_ADVANCED(CMAKE_EXECUTABLE_FORMAT)
|
|
MARK_AS_ADVANCED(CMAKE_LIBRARY_OUTPUT_DIRECTORY)
|
|
MARK_AS_ADVANCED(CMAKE_OSX_ARCHITECTURES)
|
|
MARK_AS_ADVANCED(CMAKE_OSX_DEPLOYMENT_TARGET)
|
|
MARK_AS_ADVANCED(CMAKE_OSX_SYSROOT)
|
|
MARK_AS_ADVANCED(CMAKE_RUNTIME_OUTPUT_DIRECTORY)
|
|
MARK_AS_ADVANCED(CMAKE_USE_CHRPATH)
|
|
|