Tyro/CMakeLists.txt

133 lines
4.0 KiB
CMake
Raw Normal View History

2015-07-10 16:24:09 -04:00
################################################################################
# Setup
################################################################################
2015-10-29 09:47:56 -04:00
cmake_minimum_required (VERSION 3.0)
2015-10-23 16:26:48 -04:00
2015-10-29 13:55:01 -04:00
set(CMAKE_CXX_STANDARD 11)
2015-10-23 16:26:48 -04:00
# Hunter for dependency management
include("cmake/HunterGate.cmake")
HunterGate(
URL "https://github.com/ruslo/hunter/archive/v0.12.24.tar.gz"
SHA1 "a25a7fa55c204a8126efd1f48593a662925b26da"
)
2015-10-23 16:26:48 -04:00
2015-07-10 16:24:09 -04:00
project(Tyro)
2015-07-10 16:24:09 -04:00
include_directories(${PROJECT_SOURCE_DIR} ${PROJECT_SOURCE_DIR}/include)
# C++11, please
include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
if(COMPILER_SUPPORTS_CXX11)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
2015-07-10 16:24:09 -04:00
elseif(COMPILER_SUPPORTS_CXX0X)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
2015-10-29 09:47:56 -04:00
# Need this for Visual Studio compilers
2015-07-10 16:24:09 -04:00
else()
message(FATAL_ERROR "Compiler ${CMAKE_CXX_COMPILER} has no C++11 support.")
2015-07-10 16:24:09 -04:00
endif()
2015-10-29 13:55:01 -04:00
# Silence some useless errors
2015-10-29 14:09:27 -04:00
if (${CMAKE_CXX_COMPILER_ID} MATCHES "Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-potentially-evaluated-expression")
2015-10-29 13:55:01 -04:00
endif()
2015-07-10 16:24:09 -04:00
# wxwidgets stuff
2015-10-29 09:47:56 -04:00
set(wxWidgets_CONFIG_OPTIONS --static)
2015-10-29 13:55:01 -04:00
unset(WXSETUP_wxUSE_WEBVIEW_WEBKIT)
hunter_add_package(wxWidgets)
2015-07-10 16:24:09 -04:00
find_package(wxWidgets COMPONENTS core base aui stc adv REQUIRED)
include("${wxWidgets_USE_FILE}")
#libssh2
set(CMAKE_MODULE_PATH ${Tyro_SOURCE_DIR}/cmake)
2015-10-29 14:09:27 -04:00
if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
hunter_add_package(libssh2)
endif()
find_package(LibSSH2 REQUIRED)
if (LIBSSH2_FOUND)
set (INCLUDE_DIRS ${INCLUDE_DIRS} ${LIBSSH2_INCLUDE_DIR})
else (LIBSSH2_FOUND)
message ( FATAL_ERROR "Could not find LibSSH2" )
endif (LIBSSH2_FOUND)
2015-07-10 16:24:09 -04:00
include_directories(${INCLUDE_DIRS})
# set some platform-specific flags
2015-10-29 09:47:56 -04:00
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
2015-10-29 13:55:01 -04:00
set(CMAKE_CXX_FLAGS "--sysroot ${CMAKE_OSX_SYSROOT} ${CMAKE_CXX_FLAGS} -stdlib=libc++")
2015-07-10 16:24:09 -04:00
add_definitions(-D_WCHAR_H_CPLUSPLUS_98_CONFORMANCE_ -D__WXMAC__)
2015-10-29 13:55:01 -04:00
else()
add_definitions(-D_WCHAR_H_CPLUSPLUS_98_CONFORMANCE_)
2015-07-10 16:24:09 -04:00
endif()
################################################################################
# Build
################################################################################
# json library
add_library(JsonLib STATIC
include/jsoncpp.cpp)
# Build json conversion script
add_executable(json2c config/json2c.c)
add_custom_command(
TARGET JsonLib PRE_BUILD
COMMAND json2c ../config/languages.json ../config/languages_json.h languages_json
DEPENDS json2c
)
add_custom_command(
TARGET JsonLib PRE_BUILD
COMMAND json2c ../config/themes.json ../config/themes_json.h themes_json
DEPENDS json2c
)
# base library
add_library(BaseLib STATIC
src/base/SFTP.cpp
2015-07-10 16:24:09 -04:00
src/settings/Config.cpp)
# widget library
file(GLOB widget_SRC
"src/settings/*.cpp"
"src/widgets/*.cpp"
)
add_library(WidgetLib STATIC ${widget_SRC})
target_link_libraries(WidgetLib JsonLib)
2015-10-29 09:47:56 -04:00
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
2015-07-14 16:30:12 -04:00
set(MACOSX_icon_file ${CMAKE_CURRENT_SOURCE_DIR}/resources/platform/osx/tyro.icns)
set(MACOSX_BUNDLE_ICON_FILE tyro.icns)
set(MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/resources/platform/osx/Info.plist)
set_source_files_properties(${MACOSX_icon_file} PROPERTIES MACOSX_PACKAGE_LOCATION "Resources")
add_executable(Tyro MACOSX_BUNDLE
2015-07-14 16:30:12 -04:00
src/TyroApp.cpp
${MACOSX_icon_file}
)
2015-10-29 09:47:56 -04:00
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
2015-07-10 16:24:09 -04:00
add_executable(Tyro WIN32
resources/platform/msw/resource.rc
src/TyroApp.cpp)
else()
add_executable(Tyro
src/TyroApp.cpp)
endif()
#link it all
target_link_libraries(Tyro JsonLib BaseLib WidgetLib ${wxWidgets_LIBRARIES} ${Libssh2_LIBRARIES})
2015-07-10 16:24:09 -04:00
################################################################################
# Tests
################################################################################
enable_testing(true)
file(GLOB test_SRC
"tests/main.cpp"
"tests/*Test.cpp"
)
add_executable(test_runner ${test_SRC})
2015-10-29 09:47:56 -04:00
target_link_libraries(test_runner ${wxWidgets_LIBRARIES} ${Libssh2_LIBRARIES} JsonLib BaseLib WidgetLib)