Tyro/CMakeLists.txt

141 lines
4.3 KiB
CMake
Raw Normal View History

2015-07-10 16:24:09 -04:00
################################################################################
# Setup
################################################################################
2015-10-23 16:26:48 -04:00
cmake_minimum_required (VERSION 2.8)
################################################################################
set(IS_WINDOWS ${CMAKE_SYSTEM_NAME} MATCHES "Windows")
set(IS_OSX ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
################################################################################
# Hunter for dependency management
if(${IS_WINDOWS})
include("cmake/HunterGate.cmake")
HunterGate(
URL "https://github.com/ruslo/hunter/archive/v0.12.24.tar.gz"
SHA1 "a25a7fa55c204a8126efd1f48593a662925b26da"
)
endif()
################################################################################
set(IS_WINDOWS ${CMAKE_SYSTEM_NAME} MATCHES "Windows")
set(IS_OSX ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
2015-07-10 16:24:09 -04:00
project(Tyro)
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-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()
# wxwidgets stuff
2015-10-23 16:26:48 -04:00
if(${IS_WINDOWS})
hunter_add_package(libssh2)
hunter_add_package(wxWidgets)
endif()
2015-07-10 16:24:09 -04:00
find_package(wxWidgets COMPONENTS core base aui stc adv REQUIRED)
include("${wxWidgets_USE_FILE}")
set(wxWidgets_CONFIG_OPTIONS --static)
#libssh2
set(CMAKE_MODULE_PATH ${Tyro_SOURCE_DIR}/cmake)
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-23 16:26:48 -04:00
if(${IS_OSX})
2015-07-10 16:24:09 -04:00
set(CMAKE_CXX_FLAGS "--sysroot ${CMAKE_OSX_SYSROOT} ${CMAKE_CXX_FLAGS} -stdlib=libc++")
add_definitions(-D_WCHAR_H_CPLUSPLUS_98_CONFORMANCE_ -D__WXMAC__)
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-23 16:26:48 -04:00
if(${IS_OSX})
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-23 16:26:48 -04:00
elseif(${IS_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()
# Try to use nuget to install dependencies on Windows
2015-10-23 16:26:48 -04:00
#if (${IS_WINDOWS})
# add_custom_command(TARGET ${PROJECT_NAME}
# PRE_BUILD
# COMMAND nuget restore "${PROJECT_SOURCE_DIR}\\resources\\visual_studio\\packages.config" -PackagesDirectory "${CMAKE_BINARY_DIR}\\packages"
# )
#endif()
2015-07-10 16:24:09 -04:00
#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})
target_link_libraries(test_runner ${wxWidgets_LIBRARIES} ${Libssh2_LIBRARIES} JsonLib BaseLib WidgetLib)