Skip to content

Commit

Permalink
(Port to C++) cmake (giuspen#771)
Browse files Browse the repository at this point in the history
* rough cmake install

WIP

* copy js and css from data dir

* rename autoconf files to turn off autoconf

* build man pages

* adjusting cpack

* rename README -> README.md

* update travis config

* config.h.cmake

* update cmake on travis

* one more travis fix
  • Loading branch information
txe authored May 2, 2020
1 parent 0e70f62 commit ad1b09c
Show file tree
Hide file tree
Showing 16 changed files with 397 additions and 36 deletions.
27 changes: 25 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,33 @@ before_install:
sudo apt install build-essential libtool autoconf libgtkmm-3.0-dev
libgtksourceviewmm-3.0-dev libxml++2.6-dev libsqlite3-dev
libcpputest-dev autopoint gettext intltool python3-lxml libxml2-utils libgspell-1-dev
addons:
apt:
update: true

install:
- export DEPS_DIR="${HOME}/deps"
- mkdir -p ${DEPS_DIR} && cd ${DEPS_DIR}
- echo ${TRAVIS_OS_NAME}
- |
if [ "${TRAVIS_OS_NAME}" = "linux" ]; then
export CMAKE_URL="https://github.com/Kitware/CMake/releases/download/v3.17.0/cmake-3.17.0-Linux-x86_64.tar.gz";
mkdir cmake;
travis_retry wget --no-check-certificate -O - ${CMAKE_URL} | tar --strip-components=1 -xz -C cmake;
export PATH=${DEPS_DIR}/cmake/bin:${PATH};
echo ${PATH};
else
brew install cmake || brew upgrade cmake;
fi
- cmake --version
before_script:
# returns back to working dir
- cd "${TRAVIS_BUILD_DIR}"

script:
- cd future
- ./build.sh
- mkdir build
- cd build
- cmake -DCMAKE_INSTALL_PREFIX=./local_usr ../future
- make
- ./run_tests
87 changes: 79 additions & 8 deletions future/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,42 @@
cmake_minimum_required(VERSION 3.1.0)
cmake_minimum_required(VERSION 3.13.2)

project(cherrytree)
set(CT_VERSION "0.1.0")


# used to install locale, packagers might overwrite this
if(NOT PACKAGE_LOCALE_DIR)
set(PACKAGE_LOCALE_DIR "share/locale")
endif(NOT PACKAGE_LOCALE_DIR)

# used to install data, packagers might overwrite this
if(NOT SHARE_INSTALL)
set(SHARE_INSTALL "share" CACHE STRING "Data file install path. Must be a relative path (from CMAKE_INSTALL_PREFIX), with no trailing slash.")
endif(NOT SHARE_INSTALL)
set(CHERRYTREE_SHARE_INSTALL "${SHARE_INSTALL}/cherrytree")


set(CPACK_PACKAGE_NAME "cherrytree")
set(CPACK_PACKAGE_CONTACT "Giuseppe Penone <[email protected]>")
set(CPACK_PACKAGE_VENDOR ${CPACK_PACKAGE_CONTACT})
set(CPACK_PACKAGE_VERSION ${CT_VERSION})
set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README.md")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "A Hierarchical Note Taking Application, featuring Rich Text and Syntax Highlighting.")
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/../license.txt")
set(CPACK_PACKAGING_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX})
set(CPACK_PACKAGE_CHECKSUM "SHA256")
set(CPACK_PACKAGE_EXECUTABLES ${CPACK_PACKAGE_CONTACT})
set(CPACK_CREATE_DESKTOP_LINKS ${CPACK_PACKAGE_CONTACT})
set(CPACK_PACKAGE_INSTALL_DIRECTORY ${CPACK_PACKAGE_CONTACT})
set(CPACK_STRIP_FILES TRUE)

set(CPACK_DEBIAN_PACKAGE_DEPENDS "libgtkmm-3.0-dev, libgtksourceviewmm-3.0-dev, libxml++2.6-dev, libsqlite3-dev, gettext, libgspell-1-dev")
set(CPACK_DEBIAN_PACKAGE_HOMEPAGE "https://www.giuspen.com/cherrytree/")
#set(CPACK_DEBIAN_PACKAGE_SECTION "graphics") which one?
set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)

include(CPack)


set(CMAKE_CXX_STANDARD 17)

Expand All @@ -16,18 +48,17 @@ elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wthread-safety)
endif()

#add_compile_options(-pthread -Wall -Wextra -Wno-unused-parameter)
add_compile_options(-Wno-deprecated -Wno-deprecated-declarations)
add_definitions(-D_CT_VERSION="${CT_VERSION}")
add_definitions(-DGETTEXT_PACKAGE="${CPACK_PACKAGE_NAME}")
add_definitions(-DCHERRYTREE_LOCALEDIR="")


add_compile_options(-Wno-deprecated -Wno-deprecated-declarations)
if(CMAKE_BUILD_TYPE STREQUAL "")
add_compile_options(-O3)
endif()

#option(BUILD_TESTING "Build tests")

# Create the configuration files config.h in the root dir
configure_file(${CMAKE_SOURCE_DIR}/config.h.cmake ${CMAKE_SOURCE_DIR}/config.h)



include(FindPkgConfig)
pkg_check_modules(GTKMM gtkmm-3.0 REQUIRED)
Expand Down Expand Up @@ -61,3 +92,43 @@ add_subdirectory(src/ct)
enable_testing()
add_subdirectory(tests)



# rebuild man pages
set(MANFILE_FULL "${CMAKE_SOURCE_DIR}/data/cherrytree.1")
set(MANFILE_FULL_GZ "${MANFILE_FULL}.gz")
add_custom_command(
OUTPUT ${MANFILE_FULL_GZ}
COMMAND gzip -f -k --best -n "${MANFILE_FULL}"
)
add_custom_target(man_pages ALL DEPENDS ${MANFILE_FULL_GZ})

# install commands
install(TARGETS cherrytree RUNTIME DESTINATION bin)
if(${CMAKE_SYSTEM_NAME} MATCHES Linux|.*BSD|DragonFly)
# share data
install(FILES "${CMAKE_SOURCE_DIR}/data/cherrytree.desktop"
DESTINATION "${SHARE_INSTALL}/applications")
install(FILES "${CMAKE_SOURCE_DIR}/icons/cherrytree.svg"
DESTINATION "${SHARE_INSTALL}/icons/hicolor/scalable/apps")
install(FILES "${MANFILE_FULL_GZ}"
DESTINATION "${SHARE_INSTALL}/man/man1")
install(FILES
"${CMAKE_SOURCE_DIR}/data/cherrytree.mime"
"${CMAKE_SOURCE_DIR}/data/cherrytree.keys"
DESTINATION "${SHARE_INSTALL}/mime-info")
install(FILES "${CMAKE_SOURCE_DIR}/data/cherrytree.appdata.xml"
DESTINATION "${SHARE_INSTALL}/metainfo")

# share/cherrytree data
install(FILES
"${CMAKE_SOURCE_DIR}/language-specs/clisp.lang"
"${CMAKE_SOURCE_DIR}/language-specs/markdown-extra.lang"
DESTINATION "${CHERRYTREE_SHARE_INSTALL}/language-specs")
install(FILES
"${CMAKE_SOURCE_DIR}/data/script3.js"
"${CMAKE_SOURCE_DIR}/data/styles3.css"
DESTINATION "${CHERRYTREE_SHARE_INSTALL}/data")
endif()


File renamed without changes.
File renamed without changes.
10 changes: 0 additions & 10 deletions future/autogen.sh

This file was deleted.

10 changes: 0 additions & 10 deletions future/build.sh

This file was deleted.

26 changes: 26 additions & 0 deletions future/config.h.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@

#pragma once

/* Name of package */
#define PACKAGE "${PROJECT_NAME}"

/* Name of package */
#define PACKAGE_NAME "${PROJECT_NAME}"

/* The domain to use with gettext */
#define GETTEXT_PACKAGE "${PROJECT_NAME}"

/* Localization directory */
#define CHERRYTREE_LOCALEDIR "${CMAKE_INSTALL_PREFIX}/${PACKAGE_LOCALE_DIR}"

/* data directory */
#define CHERRYTREE_DATADIR "${CMAKE_INSTALL_PREFIX}/${CHERRYTREE_SHARE_INSTALL}"


/* always defined to indicate that i18n is enabled */
#cmakedefine ENABLE_NLS 1

/* folder with data for tests */
#define _UNITTEST_DATA_DIR "${CMAKE_SOURCE_DIR}/tests/data"


File renamed without changes.
41 changes: 41 additions & 0 deletions future/data/script3.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
function changeFrame(file_path){
var iframe = document.getElementById("page_frame");
iframe.src = file_path;
}

function toggleSubTree(element){
var nextSibling = element.parentElement.nextElementSibling;
if(nextSibling.tagName == 'UL'){
nextSibling.classList.toggle('hide');
if(element.textContent == '+'){
element.textContent = '-'
}else{
element.textContent = '+'
}
}
}

function expandAllSubtrees(element){
var subtrees = document.getElementsByClassName("subtree");
for(var i=0; i<subtrees.length; i++){
var subtree = subtrees[i];
subtree.classList.remove('hide');
subtree.previousElementSibling.firstChild.textContent = '-';
}
}

function collapseAllSubtrees(element){
var subtrees = document.getElementsByClassName("subtree");
for(var i=0; i<subtrees.length; i++){
var subtree = subtrees[i];
subtree.classList.add('hide');
subtree.previousElementSibling.firstChild.textContent = '+';
}
}

window.onload = function(){
var show_page = window.location.hash.substr(1);
if (show_page !== '') {
changeFrame(show_page);
}
}
Loading

0 comments on commit ad1b09c

Please sign in to comment.