-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
276 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
cmake_minimum_required(VERSION 3.0) | ||
project(fakevim VERSION 0.0.1) | ||
|
||
# Library name | ||
set(bin fakevim) | ||
|
||
# Public headers | ||
set(${bin}_public_headers | ||
fakevim/fakevimactions.h | ||
fakevim/fakevimhandler.h | ||
) | ||
|
||
# Source files common for all platforms | ||
set(${bin}_sources | ||
fakevim/fakevimactions.cpp | ||
fakevim/fakevimhandler.cpp | ||
fakevim/utils/qtcassert.cpp | ||
${${bin}_public_headers} | ||
) | ||
|
||
# Required pkg-config packages | ||
set(${bin}_pkg_config_requires) | ||
|
||
include(cmake/cxx11.cmake) | ||
include(cmake/library.cmake) | ||
include(cmake/qt.cmake) | ||
include(cmake/pkg-config.cmake) | ||
|
||
# Files with Q_OBJECT macros to pass to moc utility | ||
set(CMAKE_INCLUDE_CURRENT_DIR ON) | ||
qt5_wrap_cpp(${bin}_mocced "fakevim/fakevimhandler.h") | ||
# Generate moc file with correct file name. | ||
qt5_generate_moc("fakevim/fakevimhandler.cpp" "fakevimhandler.moc") | ||
target_sources(${bin} PRIVATE ${${bin}_mocced} "fakevimhandler.moc") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
if (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 3.1) | ||
set(CMAKE_CXX_STANDARD 11) | ||
else() | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
include("${CMAKE_CURRENT_LIST_DIR}/fakevimTargets.cmake") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
set(INSTALL_LIB_DIR "lib" CACHE PATH | ||
"Installation directory for libraries") | ||
set(INSTALL_BIN_DIR "bin" CACHE PATH | ||
"Installation directory for executables") | ||
set(INSTALL_INCLUDE_DIR "include/${bin}" CACHE PATH | ||
"Installation directory for header files") | ||
set(INSTALL_CMAKE_DIR "lib/cmake/${bin}" CACHE PATH | ||
"Installation directory for CMake files") | ||
|
||
# Shared or static library | ||
option(CREATE_STATIC_LIBRARY "Create static library" OFF) | ||
if (CREATE_STATIC_LIBRARY) | ||
set(libtype STATIC) | ||
else() | ||
set(libtype SHARED) | ||
endif() | ||
|
||
add_library(${bin} ${libtype} ${${bin}_sources}) | ||
set_target_properties(${bin} PROPERTIES | ||
VERSION ${PROJECT_VERSION} | ||
SOVERSION ${PROJECT_VERSION_MAJOR} | ||
) | ||
|
||
# Headers | ||
set(exports_dir "${CMAKE_CURRENT_BINARY_DIR}/exports") | ||
set(export_header "${exports_dir}/private/${bin}_export.h") | ||
set_target_properties(${bin} PROPERTIES | ||
PUBLIC_HEADER "${${bin}_public_headers}" | ||
PRIVATE_HEADER "${export_header}") | ||
|
||
target_include_directories(${bin} | ||
PRIVATE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/${bin}> | ||
INTERFACE $<INSTALL_INTERFACE:include/${bin}> | ||
) | ||
|
||
install( | ||
TARGETS ${bin} EXPORT ${bin}Targets | ||
RUNTIME DESTINATION "${INSTALL_BIN_DIR}" COMPONENT bin | ||
LIBRARY DESTINATION "${INSTALL_LIB_DIR}" COMPONENT lib | ||
ARCHIVE DESTINATION "${INSTALL_LIB_DIR}" COMPONENT lib | ||
PUBLIC_HEADER DESTINATION "${INSTALL_INCLUDE_DIR}" COMPONENT dev | ||
PRIVATE_HEADER DESTINATION "${INSTALL_INCLUDE_DIR}/private" COMPONENT dev | ||
) | ||
|
||
# Generate and install CMake files for the library so `find_package(<Library>)` can be used with CMake. | ||
# For more info: https://cmake.org/cmake/help/v3.0/manual/cmake-packages.7.html#creating-packages | ||
include(GenerateExportHeader) | ||
generate_export_header(${bin} EXPORT_FILE_NAME "${export_header}") | ||
target_include_directories(${bin} PRIVATE "${exports_dir}") | ||
|
||
include(CMakePackageConfigHelpers) | ||
write_basic_package_version_file( | ||
"${CMAKE_CURRENT_BINARY_DIR}/${bin}ConfigVersion.cmake" | ||
VERSION ${PROJECT_VERSION} | ||
COMPATIBILITY AnyNewerVersion | ||
) | ||
|
||
export( | ||
EXPORT ${bin}Targets | ||
FILE "${CMAKE_CURRENT_BINARY_DIR}/${bin}Targets.cmake" | ||
) | ||
configure_file( | ||
cmake/${bin}Config.cmake | ||
"${CMAKE_CURRENT_BINARY_DIR}/${bin}Config.cmake" | ||
COPYONLY | ||
) | ||
|
||
install( | ||
EXPORT ${bin}Targets | ||
FILE | ||
${bin}Targets.cmake | ||
DESTINATION | ||
"${INSTALL_CMAKE_DIR}" | ||
COMPONENT | ||
dev | ||
) | ||
install( | ||
FILES | ||
"${CMAKE_CURRENT_BINARY_DIR}/${bin}Config.cmake" | ||
"${CMAKE_CURRENT_BINARY_DIR}/${bin}ConfigVersion.cmake" | ||
DESTINATION | ||
"${INSTALL_CMAKE_DIR}" | ||
COMPONENT | ||
dev | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
set(PKG_CONFIG_REQUIRES "${${bin}_pkg_config_requires}") | ||
set(PKG_CONFIG_LIBDIR "\${prefix}/lib") | ||
set(PKG_CONFIG_INCLUDEDIR "\${prefix}/include/${bin}") | ||
set(PKG_CONFIG_LIBS "-L\${libdir} -l${bin}") | ||
set(PKG_CONFIG_CFLAGS "-I\${includedir}") | ||
|
||
configure_file( | ||
"${CMAKE_CURRENT_SOURCE_DIR}/pkg-config.pc.in" | ||
"${CMAKE_CURRENT_BINARY_DIR}/${bin}.pc" | ||
) | ||
|
||
set(INSTALL_PKG_CONFIG_DIR "${CMAKE_INSTALL_PREFIX}/lib/pkgconfig" | ||
CACHE PATH "Installation directory for pkg-config files") | ||
|
||
install( | ||
FILES | ||
"${CMAKE_CURRENT_BINARY_DIR}/${bin}.pc" | ||
DESTINATION | ||
"${INSTALL_PKG_CONFIG_DIR}" | ||
COMPONENT | ||
dev | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
find_package(Qt5Widgets REQUIRED) | ||
|
||
include_directories(${Qt5Gui_PRIVATE_INCLUDE_DIRS}) | ||
target_link_libraries(${bin} Qt5::Widgets) | ||
|
||
set(${bin}_pkg_config_requires ${${bin}_pkg_config_requires} Qt5::Widgets) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
cmake_minimum_required(VERSION 2.8.8) | ||
project(fakevim_example) | ||
|
||
find_package(fakevim REQUIRED) | ||
find_package(Qt5Widgets REQUIRED) | ||
|
||
set(bin fakevim_example) | ||
add_executable(${bin} main.cpp editor.cpp) | ||
|
||
set(CMAKE_INCLUDE_CURRENT_DIR ON) | ||
qt5_generate_moc("editor.cpp" "editor.moc") | ||
target_sources(${bin} PRIVATE "editor.moc") | ||
|
||
target_link_libraries(${bin} fakevim) | ||
target_link_libraries(${bin} Qt5::Widgets) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
|
||
#ifndef FAKEVIM_EXPORT_H | ||
#define FAKEVIM_EXPORT_H | ||
|
||
#ifdef FAKEVIM_STATIC_DEFINE | ||
# define FAKEVIM_EXPORT | ||
# define FAKEVIM_NO_EXPORT | ||
#else | ||
# ifndef FAKEVIM_EXPORT | ||
# ifdef fakevim_EXPORTS | ||
/* We are building this library */ | ||
# define FAKEVIM_EXPORT __attribute__((visibility("default"))) | ||
# else | ||
/* We are using this library */ | ||
# define FAKEVIM_EXPORT __attribute__((visibility("default"))) | ||
# endif | ||
# endif | ||
|
||
# ifndef FAKEVIM_NO_EXPORT | ||
# define FAKEVIM_NO_EXPORT __attribute__((visibility("hidden"))) | ||
# endif | ||
#endif | ||
|
||
#ifndef FAKEVIM_DEPRECATED | ||
# define FAKEVIM_DEPRECATED __attribute__ ((__deprecated__)) | ||
#endif | ||
|
||
#ifndef FAKEVIM_DEPRECATED_EXPORT | ||
# define FAKEVIM_DEPRECATED_EXPORT FAKEVIM_EXPORT FAKEVIM_DEPRECATED | ||
#endif | ||
|
||
#ifndef FAKEVIM_DEPRECATED_NO_EXPORT | ||
# define FAKEVIM_DEPRECATED_NO_EXPORT FAKEVIM_NO_EXPORT FAKEVIM_DEPRECATED | ||
#endif | ||
|
||
#if 0 /* DEFINE_NO_DEPRECATED */ | ||
# ifndef FAKEVIM_NO_DEPRECATED | ||
# define FAKEVIM_NO_DEPRECATED | ||
# endif | ||
#endif | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
Name: ${PROJECT_NAME} | ||
Description: ${PROJECT_DESCRIPTION} | ||
Version: ${PROJECT_VERSION} | ||
Requires: ${PKG_CONFIG_REQUIRES} | ||
|
||
prefix=${CMAKE_INSTALL_PREFIX} | ||
includedir=${PKG_CONFIG_INCLUDEDIR} | ||
libdir=${PKG_CONFIG_LIBDIR} | ||
|
||
Libs: ${PKG_CONFIG_LIBS} | ||
Cflags: ${PKG_CONFIG_CFLAGS} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
cmake_minimum_required(VERSION 2.8.8) | ||
project(fakevim_tests) | ||
|
||
find_package(fakevim REQUIRED) | ||
find_package(Qt5Widgets REQUIRED) | ||
find_package(Qt5Test REQUIRED) | ||
|
||
set(bin fakevim_tests) | ||
add_executable(${bin} fakevim_test.cpp ../example/editor.cpp) | ||
|
||
set(CMAKE_INCLUDE_CURRENT_DIR ON) | ||
qt5_wrap_cpp(${bin}_mocced "fakevimplugin.h") | ||
qt5_generate_moc("../example/editor.cpp" "editor.moc") | ||
target_sources(${bin} PRIVATE ${${bin}_mocced} "editor.moc") | ||
|
||
target_link_libraries(${bin} fakevim) | ||
target_link_libraries(${bin} Qt5::Widgets Qt5::Test) |