Tyro/CMakeLists.txt

137 lines
4.1 KiB
CMake
Raw Normal View History

2015-07-10 16:24:09 -04:00
################################################################################
# Setup
################################################################################
cmake_minimum_required (VERSION 2.8)
2015-10-23 16:26:48 -04:00
2015-10-29 13:55:01 -04:00
set(CMAKE_CXX_STANDARD 11)
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)
2016-01-13 09:29:09 -05:00
# C11, please
include(CheckCCompilerFlag)
CHECK_C_COMPILER_FLAG("-std=c11" COMPILER_SUPPORTS_C11)
if (COMPILER_SUPPORTS_C11)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c11")
else()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99")
endif()
2015-07-10 16:24:09 -04:00
# C++11, please
include(CheckCXXCompilerFlag)
2019-06-04 16:07:21 -04:00
CHECK_CXX_COMPILER_FLAG("-std=c++17" COMPILER_SUPPORTS_CXX17)
2015-07-10 16:24:09 -04:00
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
2019-06-04 16:07:21 -04:00
if(COMPILER_SUPPORTS_CXX17)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17")
elseif(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()
2019-05-14 16:23:47 -04:00
2015-10-29 14:09:27 -04:00
if (${CMAKE_CXX_COMPILER_ID} MATCHES "Clang")
2019-05-14 16:23:47 -04:00
# Silence some useless errors
2015-10-29 14:09:27 -04:00
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-potentially-evaluated-expression")
2019-05-14 16:23:47 -04:00
# Set the correct standard lib
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -stdlib=libc++ -lc++abi")
2015-10-29 13:55:01 -04:00
endif()
2015-07-10 16:24:09 -04:00
# wxwidgets stuff
2015-11-18 15:43:04 -05:00
#set(wxWidgets_CONFIG_OPTIONS --static)
2015-07-10 16:24:09 -04:00
find_package(wxWidgets COMPONENTS core base aui stc adv REQUIRED)
include("${wxWidgets_USE_FILE}")
#libssh2
2019-06-04 13:53:00 -04:00
#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-29 09:47:56 -04:00
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
2020-07-16 10:09:19 -04:00
#set(MACOSX_DEPLOYMENT_TARGET 10.4)
2019-06-04 16:07:21 -04:00
#set(CMAKE_CXX_FLAGS "--sysroot ${CMAKE_OSX_SYSROOT} ${CMAKE_CXX_FLAGS} -stdlib=libc++")
add_definitions(-D__WXMAC__)
2015-10-29 13:55:01 -04:00
else()
2019-06-04 16:07:21 -04:00
#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
2019-06-04 16:07:21 -04:00
#add_library(BaseLib STATIC
# src/base/SFTP.cpp)
2015-07-10 16:24:09 -04:00
# 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
2019-06-04 16:07:21 -04:00
target_link_libraries(Tyro JsonLib WidgetLib ${wxWidgets_LIBRARIES})# BaseLib ${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 WidgetLib) #BaseLib