"Fossies" - the Fresh Open Source Software Archive

Member "cutter-1.8.2/src/CMakeLists.txt" (20 May 2019, 7346 Bytes) of package /linux/privat/cutter-1.8.2.tar.gz:


As a special service "Fossies" has tried to format the requested text file into HTML format (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. See also the latest Fossies "Diffs" side-by-side code changes report for "CMakeLists.txt": 1.8.1_vs_1.8.2.

    1 
    2 cmake_minimum_required(VERSION 3.1)
    3 
    4 if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.12.0")
    5     cmake_policy(SET CMP0074 NEW)
    6 endif()
    7 
    8 list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
    9 include(DisallowInSource)
   10 
   11 set(CUTTER_PYTHON_MIN 3.5)
   12 
   13 option(CUTTER_ENABLE_PYTHON "Enable Python integration. Requires Python >= ${CUTTER_PYTHON_MIN}." OFF)
   14 option(CUTTER_ENABLE_PYTHON_BINDINGS "Enable generating Python bindings with Shiboken2. Unused if CUTTER_ENABLE_PYTHON=OFF." OFF)
   15 option(CUTTER_ENABLE_CRASH_REPORTS "Enable crash report system. Unused if CUTTER_ENABLE_CRASH_REPORTS=OFF" OFF)
   16 
   17 if(NOT CUTTER_ENABLE_PYTHON)
   18     set(CUTTER_ENABLE_PYTHON_BINDINGS OFF)
   19 endif()
   20 
   21 
   22 # Parse Cutter.pro to get filenames
   23 include(QMakeProParse)
   24 configure_file("${CMAKE_CURRENT_SOURCE_DIR}/Cutter.pro"
   25         "${CMAKE_CURRENT_BINARY_DIR}/Cutter.pro"
   26         COPYONLY) # trigger reconfigure if Cutter.pro changes
   27 parse_qmake_pro("${CMAKE_CURRENT_BINARY_DIR}/Cutter.pro" CUTTER_PRO)
   28 set(SOURCE_FILES ${CUTTER_PRO_SOURCES})
   29 set(HEADER_FILES ${CUTTER_PRO_HEADERS})
   30 set(UI_FILES ${CUTTER_PRO_FORMS})
   31 set(QRC_FILES ${CUTTER_PRO_RESOURCES})
   32 set(CUTTER_VERSION_MAJOR "${CUTTER_PRO_CUTTER_VERSION_MAJOR}")
   33 set(CUTTER_VERSION_MINOR "${CUTTER_PRO_CUTTER_VERSION_MINOR}")
   34 set(CUTTER_VERSION_PATCH "${CUTTER_PRO_CUTTER_VERSION_PATCH}")
   35 
   36 set(CUTTER_VERSION_FULL "${CUTTER_VERSION_MAJOR}.${CUTTER_VERSION_MINOR}.${CUTTER_VERSION_PATCH}")
   37 
   38 project(Cutter VERSION "${CUTTER_VERSION_FULL}")
   39 
   40 set(CMAKE_CXX_STANDARD 11)
   41 
   42 include_directories(core widgets common plugins)
   43 
   44 set(CMAKE_INCLUDE_CURRENT_DIR ON)
   45 set(CMAKE_AUTOMOC ON)
   46 set(CMAKE_AUTOUIC ON)
   47 set(CMAKE_AUTORCC ON)
   48 find_package(Qt5 REQUIRED COMPONENTS Core Widgets Gui Svg Network)
   49 
   50 
   51 if(WIN32)
   52     # use radare2 libraries from submodule on windows
   53     set(CUTTER_WIN32_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../cutter_win32")
   54     list(APPEND CMAKE_PREFIX_PATH "${CUTTER_WIN32_DIR}")
   55 
   56     if(CMAKE_SIZEOF_VOID_P EQUAL 8) # 64 bit
   57         list(APPEND CMAKE_LIBRARY_PATH "${CUTTER_WIN32_DIR}/radare2/lib64")
   58     else()
   59         list(APPEND CMAKE_LIBRARY_PATH "${CUTTER_WIN32_DIR}/radare2/lib32")
   60     endif()
   61 
   62     set(RADARE2_INCLUDE_DIRS "${CUTTER_WIN32_DIR}/radare2/include/libr" "${CUTTER_WIN32_DIR}/include")
   63 endif()
   64 
   65 
   66 find_package(Radare2 REQUIRED)
   67 include_directories(${RADARE2_INCLUDE_DIRS})
   68 link_directories(${RADARE2_LIBRARY_DIRS})
   69 
   70 if(CUTTER_ENABLE_PYTHON)
   71     find_package(PythonLibs ${CUTTER_PYTHON_MIN} REQUIRED)
   72 
   73     include_directories(${PYTHON_INCLUDE_DIRS})
   74     add_definitions(-DCUTTER_ENABLE_PYTHON)
   75 
   76     if(CUTTER_ENABLE_PYTHON_BINDINGS)
   77         find_package(PythonInterp REQUIRED)
   78         # 5.12.3 => 5.12
   79         if("${Qt5_VERSION}" MATCHES "^([0-9]+\\.[0-9]+)\\.[0-9]+")
   80             set(Shiboken2_VERSION_REQUIRED "${CMAKE_MATCH_1}")
   81         else()
   82             message(FATAL_ERROR "Failed to recognize Qt version")
   83         endif()
   84         find_package(Shiboken2 "${Shiboken2_VERSION_REQUIRED}" REQUIRED)
   85         find_package(PySide2 "${Shiboken2_VERSION_REQUIRED}" REQUIRED)
   86 
   87         get_target_property(PYSIDE_INCLUDE_DIR PySide2::pyside2 INTERFACE_INCLUDE_DIRECTORIES)
   88         list(GET PYSIDE_INCLUDE_DIR 0 PYSIDE_INCLUDE_DIR)
   89         include_directories(${PYSIDE_INCLUDE_DIR}
   90             ${PYSIDE_INCLUDE_DIR}/QtCore
   91             ${PYSIDE_INCLUDE_DIR}/QtGui
   92             ${PYSIDE_INCLUDE_DIR}/QtWidgets)
   93 
   94         add_definitions(-DCUTTER_ENABLE_PYTHON_BINDINGS)
   95     endif()
   96 endif()
   97 
   98 
   99 
  100 message(STATUS "")
  101 message(STATUS "Building Cutter version ${CUTTER_VERSION_FULL}")
  102 message(STATUS "Options:")
  103 message(STATUS "- Python: ${CUTTER_ENABLE_PYTHON}")
  104 message(STATUS "- Python Bindings: ${CUTTER_ENABLE_PYTHON_BINDINGS}")
  105 message(STATUS "- Crash Handling: ${CUTTER_ENABLE_CRASH_REPORTS}")
  106 message(STATUS "")
  107 
  108 
  109 include(QMakeConfigureFile)
  110 qmake_configure_file("${CMAKE_CURRENT_SOURCE_DIR}/CutterConfig.h.in"
  111         "${CMAKE_CURRENT_BINARY_DIR}/CutterConfig.h")
  112 
  113 
  114 if(CUTTER_ENABLE_PYTHON_BINDINGS)
  115     set(BINDINGS_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/bindings")
  116     set(BINDINGS_BUILD_DIR "${CMAKE_CURRENT_BINARY_DIR}/bindings")
  117 
  118     configure_file("${BINDINGS_SRC_DIR}/bindings.xml" "${BINDINGS_BUILD_DIR}/bindings.xml" COPYONLY) # trigger reconfigure if file changes
  119 
  120     execute_process(COMMAND "${PYTHON_EXECUTABLE}" "${BINDINGS_SRC_DIR}/src_list.py" cmake "${BINDINGS_BUILD_DIR}" OUTPUT_VARIABLE BINDINGS_SOURCE)
  121 
  122     set_property(SOURCE ${BINDINGS_SOURCE} PROPERTY SKIP_AUTOGEN ON)
  123 
  124     include_directories("${BINDINGS_BUILD_DIR}/CutterBindings")
  125 
  126     add_custom_command(OUTPUT ${BINDINGS_SOURCE}
  127             COMMAND Shiboken2::shiboken2 --project-file="${BINDINGS_BUILD_DIR}/bindings.txt"
  128             DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/bindings/bindings.xml" "${BINDINGS_BUILD_DIR}/bindings.txt"
  129             IMPLICIT_DEPENDS CXX "${CMAKE_CURRENT_SOURCE_DIR}/bindings/bindings.h"
  130             COMMENT "Generating Python bindings with shiboken2")
  131 else()
  132     set(BINDINGS_SOURCE "")
  133 endif()
  134 
  135 
  136 
  137 if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU"
  138         OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
  139     add_definitions(-Wall -Wextra)
  140     set_source_files_properties(${BINDINGS_SOURCE} PROPERTIES COMPILE_FLAGS -w)
  141 endif()
  142 
  143 
  144 add_executable(Cutter MACOSX_BUNDLE ${UI_FILES} ${QRC_FILES} ${SOURCE_FILES} ${HEADER_FILES} ${BINDINGS_SOURCE})
  145 set_target_properties(Cutter PROPERTIES MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/macos/Info.plist")
  146 
  147 if(CUTTER_ENABLE_CRASH_REPORTS)
  148     set(THREADS_PREFER_PTHREAD_FLAG ON)
  149     find_package(Threads REQUIRED)
  150     target_link_libraries(Cutter Threads::Threads)
  151     
  152     add_definitions(-DCUTTER_ENABLE_CRASH_REPORTS)
  153     set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g ")
  154     if(DEFINED BREAKPAD_FRAMEWORK_DIR)
  155         include_directories("${BREAKPAD_FRAMEWORK_DIR}/Breakpad.framework/Headers")
  156         set_target_properties(Cutter PROPERTIES LINK_FLAGS "-Wl,-F${BREAKPAD_FRAMEWORK_DIR}")
  157         target_link_libraries(Cutter "-framework Breakpad")
  158     else()
  159         find_package(Breakpad REQUIRED)
  160         include_directories(${BREAKPAD_INCLUDE_DIRS})
  161         target_link_libraries(Cutter ${BREAKPAD_LINK_LIBRARIES})
  162     endif()
  163 endif()
  164 
  165 target_link_libraries(Cutter Qt5::Core Qt5::Widgets Qt5::Gui Qt5::Svg Qt5::Network)
  166 target_link_libraries(Cutter ${RADARE2_LIBRARIES})
  167 if(CUTTER_ENABLE_PYTHON)
  168     target_link_libraries(Cutter ${PYTHON_LIBRARIES})
  169     if(CUTTER_ENABLE_PYTHON_BINDINGS)
  170         target_link_libraries(Cutter Shiboken2::libshiboken PySide2::pyside2)
  171 
  172         get_target_property(BINDINGS_INCLUDE_DIRS Cutter INCLUDE_DIRECTORIES)
  173         if(APPLE AND _qt5Core_install_prefix)
  174             list(APPEND BINDINGS_INCLUDE_DIRS "${_qt5Core_install_prefix}/include")
  175             list(APPEND BINDINGS_INCLUDE_DIRS "${_qt5Core_install_prefix}/include/QtCore")
  176             list(APPEND BINDINGS_INCLUDE_DIRS "${_qt5Core_install_prefix}/include/QtGui")
  177             list(APPEND BINDINGS_INCLUDE_DIRS "${_qt5Core_install_prefix}/include/QtWidgets")
  178         endif()
  179         list(APPEND BINDINGS_INCLUDE_DIRS ${Qt5Core_INCLUDE_DIRS} ${Qt5Widgets_INCLUDE_DIRS} ${Qt5Gui_INCLUDE_DIRS})
  180         list(APPEND BINDINGS_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}")
  181         string(REPLACE ";" ":" BINDINGS_INCLUDE_DIRS "${BINDINGS_INCLUDE_DIRS}")
  182 
  183         qmake_configure_file("${BINDINGS_SRC_DIR}/bindings.txt.in" "${BINDINGS_BUILD_DIR}/bindings.txt")
  184     endif()
  185 endif()
  186 
  187