2016-02-16 18:02:22 +01:00
|
|
|
cmake_minimum_required(VERSION 3.0.0 FATAL_ERROR)
|
2021-08-25 14:21:57 +02:00
|
|
|
project (lgogdownloader LANGUAGES C CXX VERSION 3.8)
|
2016-01-03 22:50:29 +01:00
|
|
|
|
|
|
|
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/")
|
|
|
|
|
2019-10-26 17:57:52 +02:00
|
|
|
# Disable search for boost-cmake
|
|
|
|
# Fixes building with Boost >= 1.70.0
|
|
|
|
set(Boost_NO_BOOST_CMAKE ON)
|
|
|
|
|
2019-03-01 09:05:16 +01:00
|
|
|
option(USE_QT_GUI "Build with Qt GUI login support" OFF)
|
|
|
|
if(USE_QT_GUI)
|
|
|
|
add_definitions(-DUSE_QT_GUI_LOGIN=1)
|
|
|
|
set(CMAKE_AUTOMOC ON)
|
|
|
|
set(CMAKE_AUTOUIC ON)
|
|
|
|
endif(USE_QT_GUI)
|
|
|
|
|
2016-05-20 19:33:07 +02:00
|
|
|
find_program(READELF readelf DOC "Location of the readelf program")
|
|
|
|
find_program(GREP grep DOC "Location of the grep program")
|
2016-01-03 22:50:29 +01:00
|
|
|
find_package(Boost
|
|
|
|
REQUIRED
|
|
|
|
system
|
|
|
|
filesystem
|
|
|
|
regex
|
|
|
|
program_options
|
|
|
|
date_time
|
2017-02-17 10:14:28 +01:00
|
|
|
iostreams
|
2016-01-03 22:50:29 +01:00
|
|
|
)
|
2016-05-03 16:12:23 +02:00
|
|
|
find_package(CURL 7.32.0 REQUIRED)
|
2016-01-03 22:50:29 +01:00
|
|
|
find_package(Jsoncpp REQUIRED)
|
|
|
|
find_package(Htmlcxx REQUIRED)
|
2016-05-13 14:25:08 +02:00
|
|
|
find_package(Tinyxml2 REQUIRED)
|
2016-01-03 22:50:29 +01:00
|
|
|
find_package(Rhash REQUIRED)
|
2016-05-20 19:33:07 +02:00
|
|
|
find_package(Threads REQUIRED)
|
2018-05-29 07:56:29 +02:00
|
|
|
find_package(ZLIB REQUIRED)
|
2016-01-03 22:50:29 +01:00
|
|
|
|
|
|
|
file(GLOB SRC_FILES
|
|
|
|
main.cpp
|
2016-04-18 19:33:19 +02:00
|
|
|
src/website.cpp
|
2016-01-03 22:50:29 +01:00
|
|
|
src/downloader.cpp
|
|
|
|
src/progressbar.cpp
|
|
|
|
src/util.cpp
|
|
|
|
src/blacklist.cpp
|
|
|
|
src/gamefile.cpp
|
|
|
|
src/gamedetails.cpp
|
2017-02-17 10:14:28 +01:00
|
|
|
src/galaxyapi.cpp
|
2018-05-29 07:56:29 +02:00
|
|
|
src/ziputil.cpp
|
2016-01-03 22:50:29 +01:00
|
|
|
)
|
|
|
|
|
2019-03-01 09:05:16 +01:00
|
|
|
if(USE_QT_GUI)
|
|
|
|
find_package(Qt5Widgets CONFIG REQUIRED)
|
|
|
|
find_package(Qt5WebEngineWidgets CONFIG REQUIRED)
|
|
|
|
|
|
|
|
file(GLOB QT_GUI_SRC_FILES
|
|
|
|
src/gui_login.cpp
|
|
|
|
)
|
|
|
|
list(APPEND SRC_FILES ${QT_GUI_SRC_FILES})
|
|
|
|
endif(USE_QT_GUI)
|
|
|
|
|
|
|
|
|
2016-01-03 22:50:29 +01:00
|
|
|
set(GIT_CHECKOUT FALSE)
|
|
|
|
if(EXISTS ${PROJECT_SOURCE_DIR}/.git)
|
|
|
|
if(NOT EXISTS ${PROJECT_SOURCE_DIR}/.git/shallow)
|
|
|
|
find_package(Git)
|
|
|
|
if(GIT_FOUND)
|
|
|
|
set(GIT_CHECKOUT TRUE)
|
|
|
|
else(GIT_FOUND)
|
|
|
|
message(WARNING "Git executable not found")
|
|
|
|
endif(GIT_FOUND)
|
|
|
|
else(NOT EXISTS ${PROJECT_SOURCE_DIR}/.git/shallow)
|
|
|
|
message(STATUS "Shallow Git clone detected, not attempting to retrieve version info")
|
|
|
|
endif(NOT EXISTS ${PROJECT_SOURCE_DIR}/.git/shallow)
|
|
|
|
endif(EXISTS ${PROJECT_SOURCE_DIR}/.git)
|
|
|
|
|
|
|
|
if(GIT_CHECKOUT)
|
|
|
|
execute_process(COMMAND ${GIT_EXECUTABLE} diff --shortstat
|
|
|
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
|
|
|
OUTPUT_VARIABLE GIT_SHORTSTAT
|
|
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
|
|
)
|
|
|
|
execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse --short HEAD
|
|
|
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
|
|
|
OUTPUT_VARIABLE GIT_REV_PARSE
|
|
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
|
|
)
|
|
|
|
if(GIT_SHORTSTAT)
|
|
|
|
set(GIT_DIRTY ON)
|
|
|
|
endif(GIT_SHORTSTAT)
|
|
|
|
|
|
|
|
if(GIT_DIRTY)
|
|
|
|
set(PROJECT_VERSION_MINOR ${PROJECT_VERSION_MINOR}M)
|
|
|
|
endif(GIT_DIRTY)
|
|
|
|
|
|
|
|
set(PROJECT_VERSION_PATCH ${GIT_REV_PARSE})
|
|
|
|
set(PROJECT_VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH})
|
|
|
|
endif(GIT_CHECKOUT)
|
|
|
|
|
|
|
|
set(VERSION_NUMBER ${PROJECT_VERSION})
|
|
|
|
set(VERSION_STRING "LGOGDownloader ${VERSION_NUMBER}")
|
2018-07-01 21:51:32 +02:00
|
|
|
set(DEFAULT_USER_AGENT "LGOGDownloader/${VERSION_NUMBER} (${CMAKE_SYSTEM_NAME} ${CMAKE_SYSTEM_PROCESSOR})")
|
2016-01-03 22:50:29 +01:00
|
|
|
|
2018-07-01 21:51:32 +02:00
|
|
|
add_definitions(-D_FILE_OFFSET_BITS=64 -DVERSION_NUMBER="${VERSION_NUMBER}" -DVERSION_STRING="${VERSION_STRING}" -DDEFAULT_USER_AGENT="${DEFAULT_USER_AGENT}")
|
2016-01-03 22:50:29 +01:00
|
|
|
|
|
|
|
add_executable (${PROJECT_NAME} ${SRC_FILES})
|
|
|
|
|
|
|
|
|
|
|
|
target_include_directories(${PROJECT_NAME}
|
|
|
|
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
|
|
|
|
PRIVATE ${Boost_INCLUDE_DIRS}
|
|
|
|
PRIVATE ${CURL_INCLUDE_DIRS}
|
|
|
|
PRIVATE ${OAuth_INCLUDE_DIRS}
|
|
|
|
PRIVATE ${Jsoncpp_INCLUDE_DIRS}
|
|
|
|
PRIVATE ${Htmlcxx_INCLUDE_DIRS}
|
2016-05-13 14:25:08 +02:00
|
|
|
PRIVATE ${Tinyxml2_INCLUDE_DIRS}
|
2016-01-03 22:50:29 +01:00
|
|
|
PRIVATE ${Rhash_INCLUDE_DIRS}
|
2018-05-29 07:56:29 +02:00
|
|
|
PRIVATE ${ZLIB_INCLUDE_DIRS}
|
2016-01-03 22:50:29 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
target_link_libraries(${PROJECT_NAME}
|
|
|
|
PRIVATE ${Boost_LIBRARIES}
|
|
|
|
PRIVATE ${CURL_LIBRARIES}
|
|
|
|
PRIVATE ${OAuth_LIBRARIES}
|
|
|
|
PRIVATE ${Jsoncpp_LIBRARIES}
|
|
|
|
PRIVATE ${Htmlcxx_LIBRARIES}
|
2016-05-13 14:25:08 +02:00
|
|
|
PRIVATE ${Tinyxml2_LIBRARIES}
|
2016-01-03 22:50:29 +01:00
|
|
|
PRIVATE ${Rhash_LIBRARIES}
|
2016-05-20 19:33:07 +02:00
|
|
|
PRIVATE ${CMAKE_THREAD_LIBS_INIT}
|
2018-05-29 07:56:29 +02:00
|
|
|
PRIVATE ${ZLIB_LIBRARIES}
|
2016-05-20 19:33:07 +02:00
|
|
|
)
|
|
|
|
|
2019-07-12 22:16:42 +02:00
|
|
|
# Check if libatomic is needed in order to use std::atomic, and add
|
|
|
|
# it to the list of JavaScriptCore libraries.
|
|
|
|
file(WRITE ${CMAKE_BINARY_DIR}/test_atomic.cpp
|
|
|
|
"#include <atomic>\n"
|
|
|
|
"int main() { std::atomic<int64_t> i(0); i++; return 0; }\n")
|
|
|
|
try_compile(ATOMIC_BUILD_SUCCEEDED ${CMAKE_BINARY_DIR} ${CMAKE_BINARY_DIR}/test_atomic.cpp)
|
|
|
|
if (NOT ATOMIC_BUILD_SUCCEEDED)
|
|
|
|
target_link_libraries(${PROJECT_NAME}
|
|
|
|
PRIVATE -latomic
|
|
|
|
)
|
|
|
|
endif ()
|
|
|
|
file(REMOVE ${CMAKE_BINARY_DIR}/test_atomic.cpp)
|
|
|
|
|
2019-03-01 09:05:16 +01:00
|
|
|
if(USE_QT_GUI)
|
|
|
|
target_link_libraries(${PROJECT_NAME}
|
|
|
|
PRIVATE Qt5::Widgets
|
|
|
|
PRIVATE Qt5::WebEngineWidgets
|
|
|
|
)
|
|
|
|
endif(USE_QT_GUI)
|
|
|
|
|
2016-01-03 22:50:29 +01:00
|
|
|
if(MSVC)
|
|
|
|
# Force to always compile with W4
|
|
|
|
if(CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
|
|
|
|
string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
|
|
|
else()
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4")
|
|
|
|
endif()
|
2016-02-16 18:56:05 +01:00
|
|
|
elseif(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
2016-01-03 22:50:29 +01:00
|
|
|
# Update if necessary
|
2016-05-13 14:25:08 +02:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Wextra -Wno-long-long -fexceptions")
|
2016-01-03 22:50:29 +01:00
|
|
|
endif()
|
|
|
|
|
|
|
|
set(INSTALL_BIN_DIR bin CACHE PATH "Installation directory for executables")
|
|
|
|
set(INSTALL_SHARE_DIR share CACHE PATH "Installation directory for resource files")
|
|
|
|
|
|
|
|
install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}${CMAKE_EXECUTABLE_SUFFIX} DESTINATION ${INSTALL_BIN_DIR})
|
|
|
|
add_subdirectory(man)
|