CMakeLists.txt (4230B)
1 include(CheckCXXCompilerFlag) 2 3 find_package(Boost 1.56 REQUIRED) 4 find_package(CURL REQUIRED) 5 find_package(MiniZip REQUIRED) 6 find_package(Threads REQUIRED) 7 find_package(WDL REQUIRED) 8 9 if(WIN32) 10 # required for selecting the right debug or release version 11 find_package(unofficial-sqlite3 CONFIG REQUIRED) 12 add_library(SQLite::SQLite3 INTERFACE IMPORTED) 13 target_link_libraries(SQLite::SQLite3 INTERFACE unofficial::sqlite3::sqlite3) 14 15 find_package(tinyxml2 CONFIG REQUIRED) 16 else() 17 find_package(SWELL REQUIRED) 18 find_package(LibXml2 REQUIRED) 19 find_package(SQLite3 REQUIRED) 20 21 if(NOT APPLE) 22 find_package(OpenSSL REQUIRED COMPONENTS Crypto) 23 endif() 24 endif() 25 26 find_package(Git) 27 if(GIT_FOUND) 28 execute_process( 29 COMMAND ${GIT_EXECUTABLE} rev-parse --short HEAD 30 OUTPUT_VARIABLE REAPACK_REVISION 31 OUTPUT_STRIP_TRAILING_WHITESPACE 32 RESULT_VARIABLE IS_GIT_BUILD 33 ERROR_QUIET 34 ) 35 endif() 36 37 if(NOT IS_GIT_BUILD EQUAL 0) 38 set(REAPACK_REVISION "nogit") 39 endif() 40 41 get_target_property(REAPACK_BASENAME reaper_reapack OUTPUT_NAME) 42 set(REAPACK_FILENAME "${REAPACK_BASENAME}${CMAKE_SHARED_LIBRARY_SUFFIX}") 43 44 file(STRINGS ../Extensions/ReaPack.ext REAPACK_VERSION REGEX "^@version") 45 string(SUBSTRING ${REAPACK_VERSION} 9 -1 REAPACK_VERSION) 46 string(REGEX REPLACE "[^0-9]+" ";" VERSION_LIST ${REAPACK_VERSION}) 47 list(TRANSFORM VERSION_LIST REPLACE "[^0-9]" "") 48 list(APPEND VERSION_LIST 0 0 0) 49 list(GET VERSION_LIST 0 REAPACK_VERSION_MAJOR) 50 list(GET VERSION_LIST 1 REAPACK_VERSION_MINOR) 51 list(GET VERSION_LIST 2 REAPACK_VERSION_PATCH) 52 list(GET VERSION_LIST 3 REAPACK_VERSION_TWEAK) 53 54 string(TIMESTAMP REAPACK_BUILDTIME "%b %d %Y %H:%M:%S" UTC) 55 file(STRINGS ../ABOUT.md REAPACK_COPYRIGHT REGEX "^Copyright") 56 57 configure_file(buildinfo.hpp.in buildinfo.hpp) 58 59 add_library(reapack OBJECT 60 about.cpp 61 action.cpp 62 api.cpp 63 api_misc.cpp 64 api_package.cpp 65 api_repo.cpp 66 archive.cpp 67 archive_tasks.cpp 68 browser.cpp 69 browser_entry.cpp 70 config.cpp 71 control.cpp 72 database.cpp 73 dialog.cpp $<IF:$<BOOL:${APPLE}>,dialog.mm,> 74 download.cpp 75 event.cpp 76 filedialog.cpp 77 filesystem.cpp 78 filter.cpp 79 hash.cpp 80 iconlist.cpp 81 import.cpp 82 index.cpp 83 index_v1.cpp 84 install.cpp 85 listview.cpp 86 main.cpp 87 manager.cpp 88 menu.cpp 89 metadata.cpp 90 obsquery.cpp 91 package.cpp 92 path.cpp 93 platform.cpp 94 progress.cpp 95 reapack.cpp 96 receipt.cpp 97 registry.cpp 98 remote.cpp 99 report.cpp 100 resource.rc 101 richedit$<IF:$<BOOL:${APPLE}>,.mm,$<IF:$<BOOL:${WIN32}>,-win32,-generic>.cpp> 102 serializer.cpp 103 source.cpp 104 string.cpp 105 synchronize.cpp 106 tabbar.cpp 107 task.cpp 108 thread.cpp 109 time.cpp 110 transaction.cpp 111 version.cpp 112 win32.cpp 113 xml_$<IF:$<BOOL:${LIBXML2_FOUND}>,libxml2,tinyxml2>.cpp 114 ) 115 116 target_compile_features(reapack PUBLIC cxx_std_17) 117 target_include_directories(reapack PRIVATE 118 ${CMAKE_SOURCE_DIR}/vendor ${CMAKE_SOURCE_DIR}/vendor/reaper-sdk/sdk 119 ${CMAKE_CURRENT_BINARY_DIR} 120 ) 121 122 if(WIN32) 123 target_sources(reapack PRIVATE buildinfo.rc) 124 target_compile_options(reapack PUBLIC /W3 /WX /wd4996) 125 target_compile_definitions(reapack PUBLIC NOMINMAX UNICODE) 126 target_link_libraries(reapack Bcrypt Comctl32 Comdlg32 Gdi32 Shell32 User32) 127 else() 128 target_compile_options(reapack PUBLIC 129 -Wall -Wextra -Werror 130 -Wno-unused-parameter -Wno-missing-field-initializers 131 ) 132 endif() 133 134 target_link_libraries(reapack 135 ${CMAKE_DL_LIBS} Boost::headers CURL::libcurl MiniZip::MiniZip 136 SQLite::SQLite3 Threads::Threads WDL::WDL 137 $<IF:$<BOOL:${LIBXML2_FOUND}>,LibXml2::LibXml2,tinyxml2::tinyxml2> 138 ) 139 target_compile_definitions(reapack PRIVATE CURL_DISABLE_DEPRECATION) 140 141 if(OPENSSL_FOUND) 142 if(RUNTIME_OPENSSL) 143 target_compile_definitions(reapack PRIVATE RUNTIME_OPENSSL) 144 else() 145 target_link_libraries(reapack OpenSSL::Crypto) 146 endif() 147 endif() 148 149 if(SWELL_FOUND) 150 target_link_libraries(reapack SWELL::swell) 151 152 # Transpile the Win32 resource file 153 find_package(PHP REQUIRED) 154 add_custom_command( 155 OUTPUT resource.rc_mac_dlg resource.rc_mac_menu 156 COMMAND ${CMAKE_COMMAND} -E copy 157 ${CMAKE_CURRENT_SOURCE_DIR}/resource.rc ${CMAKE_CURRENT_BINARY_DIR} 158 COMMAND ${PHP_EXECUTABLE} ${SWELL_RESGEN} --quiet resource.rc 159 DEPENDS ${SWELL_RESGEN} 160 MAIN_DEPENDENCY resource.rc 161 ) 162 endif()