From 04aaa013333a2164388f14d87453cf9f3b1e6fee Mon Sep 17 00:00:00 2001 From: jkriege2 Date: Sat, 18 May 2019 13:23:38 +0200 Subject: [PATCH] first test CMakeLists.txt --- common_compilersettings.cmake | 18 ++++++++++ common_include.cmake | 1 + lib/jkqtcommon/CMakeLists.txt | 16 +++++++++ lib/jkqtmathtext/CMakeLists.txt | 15 ++++++++ staticlib/jkqtmathtextlib/CMakeLists.txt | 44 ++++++++++++++++++++++++ 5 files changed, 94 insertions(+) create mode 100644 common_compilersettings.cmake create mode 100644 common_include.cmake create mode 100644 lib/jkqtcommon/CMakeLists.txt create mode 100644 lib/jkqtmathtext/CMakeLists.txt create mode 100644 staticlib/jkqtmathtextlib/CMakeLists.txt diff --git a/common_compilersettings.cmake b/common_compilersettings.cmake new file mode 100644 index 0000000000..4af239c83f --- /dev/null +++ b/common_compilersettings.cmake @@ -0,0 +1,18 @@ +cmake_minimum_required(VERSION 3.1) + +# configure compiler +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD_REQUIRED on) + +if(MINGW) + # COMPILER-SETTINGS FOR MINGW + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fexceptions") +elseif(MSVC) + # COMPILER-SETTINGS FOR MS VISUAL C++ + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc") + # To enable M_PI, M_E,... + add_definitions(/D_USE_MATH_DEFINES) + # To fix error: C2338: va_start argument must not + # have reference type and must not be parenthesized + add_definitions(/D_CRT_NO_VA_START_VALIDATION) +endif() diff --git a/common_include.cmake b/common_include.cmake new file mode 100644 index 0000000000..10af59f27e --- /dev/null +++ b/common_include.cmake @@ -0,0 +1 @@ +cmake_minimum_required(VERSION 3.1) diff --git a/lib/jkqtcommon/CMakeLists.txt b/lib/jkqtcommon/CMakeLists.txt new file mode 100644 index 0000000000..eb96750fac --- /dev/null +++ b/lib/jkqtcommon/CMakeLists.txt @@ -0,0 +1,16 @@ +cmake_minimum_required(VERSION 3.1) +# common definitions +include(../../common_include.cmake) + +set(SOURCE + ${SOURCE} + ${CMAKE_CURRENT_SOURCE_DIR}/jkqtptools.cpp + PARENT_SCOPE +) + +set(HEADERS + ${HEADERS} + ${CMAKE_CURRENT_SOURCE_DIR}/jkqtptools.h + ${CMAKE_CURRENT_SOURCE_DIR}/jkqtp_imexport.h + PARENT_SCOPE +) \ No newline at end of file diff --git a/lib/jkqtmathtext/CMakeLists.txt b/lib/jkqtmathtext/CMakeLists.txt new file mode 100644 index 0000000000..322eba28f0 --- /dev/null +++ b/lib/jkqtmathtext/CMakeLists.txt @@ -0,0 +1,15 @@ +cmake_minimum_required(VERSION 3.1) +# common definitions +include(../../common_include.cmake) + +set(SOURCE + ${SOURCE} + ${CMAKE_CURRENT_SOURCE_DIR}/jkqtmathtext.cpp + PARENT_SCOPE +) + +set(HEADERS + ${HEADERS} + ${CMAKE_CURRENT_SOURCE_DIR}/jkqtmathtext.h + PARENT_SCOPE +) \ No newline at end of file diff --git a/staticlib/jkqtmathtextlib/CMakeLists.txt b/staticlib/jkqtmathtextlib/CMakeLists.txt new file mode 100644 index 0000000000..77407e17e6 --- /dev/null +++ b/staticlib/jkqtmathtextlib/CMakeLists.txt @@ -0,0 +1,44 @@ +cmake_minimum_required(VERSION 3.1) +# common definitions +include(../../common_include.cmake) + + +IF(CMAKE_BUILD_TYPE MATCHES RELEASE) + SET(LIB_NAME libjkqtmathtext_static) +ELSE() + SET(LIB_NAME libjkqtmathtext_static_debug) +ENDIF(CMAKE_BUILD_TYPE MATCHES RELEASE) + + +# configure compiler +include(${CMAKE_CURRENT_SOURCE_DIR}/../../common_compilersettings.cmake) + + + + +# Find the QtWidgets library +find_package(Qt5 COMPONENTS Core Gui PrintSupport CONFIG REQUIRED) +# Find includes in corresponding build directories +set(CMAKE_INCLUDE_CURRENT_DIR ON) +# Instruct CMake to run moc automatically when needed +set(CMAKE_AUTOMOC ON) +# Create code from a list of Qt designer ui files +set(CMAKE_AUTOUIC ON) + + +# All build libraries are moved to this directory +set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}) +message(${CMAKE_CURRENT_SOURCE_DIR}) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../../lib/jkqtcommon/) +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../../lib/jkqtmathtext/) + +# define output library and properties +ADD_LIBRARY(${LIB_NAME} ${SOURCES} ${HEADERS}) +INSTALL(TARGETS ${LIB_NAME} DESTINATION bin) + +# define target +target_link_libraries(${LIB_NAME} Qt5::Core Qt5::Widgets Qt5::PrintSupport) +#target_compile_features(${LIB_NAME} PUBLIC cxx_std_11) +target_include_directories(${LIB_NAME} PUBLIC "../../lib/jkqtmathtext/") +#export(TARGETS ${LIB_NAME})