diff --git a/CMakeLists.txt b/CMakeLists.txt deleted file mode 100644 index 71b9a4d..0000000 --- a/CMakeLists.txt +++ /dev/null @@ -1,25 +0,0 @@ -cmake_minimum_required(VERSION 3.5) -project(workspace) - -set(cmd "dirname -z $(realpath CMakeLists.txt)") -execute_process(COMMAND bash -c ${cmd} - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} - RESULT_VARIABLE result - OUTPUT_VARIABLE ORIGIN) - -include(${ORIGIN}/cmake/customMacro.cmake) -include(${ORIGIN}/cmake/python.cmake) -set(ROOT_DIR "${CMAKE_SOURCE_DIR}") -set(CMAKE_INSTALL_PREFIX "${ROOT_DIR}/install") -file(MAKE_DIRECTORY ${CMAKE_INSTALL_PREFIX}) - -PREPARE_PYTHON() - -SUBDIRLIST(SUBDIRS ${CMAKE_CURRENT_SOURCE_DIR}/src) -SORT_SUBDIRS() -FOREACH(subdir ${SUBDIRS}) - message("== Configuration of ${subdir} started") - ADD_SUBDIRECTORY(src/${subdir}) - message("== Configuration of ${subdir} finished!") -ENDFOREACH() - diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 120000 index 0000000..e55cef2 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1 @@ +src/haricot/cmake/TopLevelCMake.txt \ No newline at end of file diff --git a/README.md b/README.md index bcc9a9a..5777c3b 100644 --- a/README.md +++ b/README.md @@ -1,17 +1,17 @@ -# Cmake_multi_repo_template +# Haricot Test of a mutli repo Cmake based template Packages can contains C++ and Python code Tested only on Linux with cmake 3.13.2 and 3.5.1 ## Usage -- `./configure` +- `./haricot` - `cd build/src/mypkg; cpack` - `cd build; ninja install` ## Features Top level CMakeLists.txt architecture -The CmakeLists.txt in packages (Subdirectories) are standards (except that they can use extra features) +The CMakeLists.txt in packages (Subdirectories) are standards (except that they can use extra features) - Build all the packages (subdiretories) - Export pkg.cmake in order to includes them in another project/package @@ -19,6 +19,10 @@ The CmakeLists.txt in packages (Subdirectories) are standards (except that they - Install targets/headers in the install directory at the root of the project - Generate .deb for each packages +## Create a new workspace + +You can create a ws that would use haricot. To do that you would just have to create a symbolic link to the TopLevelCMake.txt the setup_local.zsh and to the haricot cmd (use the repo as an example). +You can even combien workspace. ## Add a package (subdirectory) diff --git a/haricot b/haricot new file mode 120000 index 0000000..1b2c38c --- /dev/null +++ b/haricot @@ -0,0 +1 @@ +src/haricot/haricot \ No newline at end of file diff --git a/setup.zsh b/setup.zsh deleted file mode 100644 index 85b7c8d..0000000 --- a/setup.zsh +++ /dev/null @@ -1,3 +0,0 @@ -MY_SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )" -CMAKE_PREFIX_PATH=${MY_SCRIPTPATH}/build/src:${CMAKE_PREFIX_PATH} -PYTHONPATH=/home/beuzeboc/code/tmp/cmake_multi_repo_template/build/python/lib/python3.5/site-packages:${PYTHONPATH} diff --git a/setup.zsh b/setup.zsh new file mode 120000 index 0000000..5cc9001 --- /dev/null +++ b/setup.zsh @@ -0,0 +1 @@ +src/haricot/setup_local.zsh \ No newline at end of file diff --git a/setup_package.zsh b/setup_package.zsh deleted file mode 100644 index bb8147f..0000000 --- a/setup_package.zsh +++ /dev/null @@ -1,3 +0,0 @@ -CMAKE_PREFIX_PATH=/opt/guillaume:${CMAKE_PREFIX_PATH} -PYTHONPATH=/opt/guillaume/lib/python3/dist-packages:${PYTHONPATH} - diff --git a/src/a_lib/CMakeLists.txt b/src/a_lib/CMakeLists.txt index 66e5c94..81b35e7 100644 --- a/src/a_lib/CMakeLists.txt +++ b/src/a_lib/CMakeLists.txt @@ -7,7 +7,7 @@ INIT_PKG() SETUP_PYTHON_PKG() include_directories(include ${Boost_INCLUDE_DIR} ) -add_library(a_lib +add_library(a_lib SHARED src/lib.cpp) target_include_directories(a_lib PUBLIC diff --git a/src/a_lib/src/lib.cpp b/src/a_lib/src/lib.cpp index 8e6cb59..31a09a7 100644 --- a/src/a_lib/src/lib.cpp +++ b/src/a_lib/src/lib.cpp @@ -10,6 +10,7 @@ void liba_function() std::string s("2001-10-9"); //2001-October-09 date d(from_simple_string(s)); std::cout << to_simple_string(d) << std::endl; + std::cout << "this is a_lib" << std::endl; } catch(std::exception& e) { std::cout << " Exception: " << e.what() << std::endl; diff --git a/src/haricot/CMakeLists.txt b/src/haricot/CMakeLists.txt new file mode 100644 index 0000000..e4c3cdd --- /dev/null +++ b/src/haricot/CMakeLists.txt @@ -0,0 +1,10 @@ +project(haricot) + +INIT_PKG() + +SETUP_PKG(haricot) + +install(DIRECTORY cmake/ DESTINATION share/haricot/cmake COMPONENT HARICOT) +install(FILES haricot setup_install.zsh setup_local.zsh DESTINATION share/haricot COMPONENT HARICOT) +install(FILES setup.zsh DESTINATION . COMPONENT HARICOT) +BUILDDEB() diff --git a/cmake/ConfigVersion.cmake b/src/haricot/cmake/ConfigVersion.cmake similarity index 100% rename from cmake/ConfigVersion.cmake rename to src/haricot/cmake/ConfigVersion.cmake diff --git a/src/haricot/cmake/TopLevelCMake.txt b/src/haricot/cmake/TopLevelCMake.txt new file mode 100644 index 0000000..9d8bfd3 --- /dev/null +++ b/src/haricot/cmake/TopLevelCMake.txt @@ -0,0 +1,25 @@ +cmake_minimum_required(VERSION 3.5) +project(workspace) + +set(cmd "dirname -z $(realpath CMakeLists.txt)") +execute_process(COMMAND bash -c ${cmd} + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + RESULT_VARIABLE result + OUTPUT_VARIABLE ORIGIN) + +include(${ORIGIN}/customMacro.cmake) +include(${ORIGIN}/python.cmake) +set(ROOT_DIR "${CMAKE_SOURCE_DIR}") +set(CMAKE_INSTALL_PREFIX "${ROOT_DIR}/install") +file(MAKE_DIRECTORY ${CMAKE_INSTALL_PREFIX}) + +PREPARE_PYTHON() + +SUBDIRLIST(SUBDIRS ${CMAKE_CURRENT_SOURCE_DIR}/src) +SORT_SUBDIRS() +FOREACH(subdir ${SUBDIRS}) + message("== Configuration of ${subdir} started") + ADD_SUBDIRECTORY(src/${subdir}) + message("== Configuration of ${subdir} finished!") +ENDFOREACH() + diff --git a/cmake/__init__.py.in b/src/haricot/cmake/__init__.py.in similarity index 100% rename from cmake/__init__.py.in rename to src/haricot/cmake/__init__.py.in diff --git a/cmake/customMacro.cmake b/src/haricot/cmake/customMacro.cmake similarity index 95% rename from cmake/customMacro.cmake rename to src/haricot/cmake/customMacro.cmake index 2e88993..8475e56 100644 --- a/cmake/customMacro.cmake +++ b/src/haricot/cmake/customMacro.cmake @@ -53,7 +53,8 @@ macro(BUILDDEB) if(EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake") include(InstallRequiredSystemLibraries) set(CPACK_SET_DESTDIR true) - set(CPACK_INSTALL_PREFIX "/opt/guillaume") + set(CPACK_PACKAGE_NAME ${PROJECT_NAME}) + set(CPACK_INSTALL_PREFIX "/opt/haricot-pkgs") set(CPACK_GENERATOR "DEB") set(CPACK_PACKAGE_DESCRIPTION "${DESCRIPTION}") set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "${SUMMARY}") @@ -71,7 +72,7 @@ macro(BUILDDEB) set(CPACK_OUTPUT_CONFIG_FILE "${PROJECT_BINARY_DIR}/CPackConfig.cmake" ) set(CPACK_DEBIAN_PACKAGE_PRIORITY "optional") - set(CPACK_DEBIAN_PACKAGE_SECTION "beuz") + set(CPACK_DEBIAN_PACKAGE_SECTION "haricot-pkgs") set(CPACK_DEBIAN_ARCHITECTURE ${CMAKE_SYSTEM_PROCESSOR}) set(CPACK_ARCHIVE_COMPONENT_INSTALL ON) include(CPack) @@ -109,14 +110,14 @@ macro(SETUP_PKG PKG_NAME) set(${PKG_NAME}_VERSION "${PKG_VERSION}" PARENT_SCOPE) set(CONF_INCLUDE_DIRS "${PROJECT_SOURCE_DIR}" "${PROJECT_BINARY_DIR}") - configure_file(${ORIGIN}/cmake/pkg-config.cmake + configure_file(${ORIGIN}/pkg-config.cmake "${PROJECT_BINARY_DIR}/${PKG_NAME}Config.cmake" @ONLY) set(CONF_INCLUDE_DIRS "${MAKE_INSTALL_PREFIX}/${PROJECT_NAME}") - configure_file(${ORIGIN}/cmake/pkg-config.cmake + configure_file(${ORIGIN}/pkg-config.cmake "${PROJECT_BINARY_DIR}/${PKG_NAME}Config.cmake" @ONLY) - configure_file(${ORIGIN}/cmake/ConfigVersion.cmake + configure_file(${ORIGIN}/ConfigVersion.cmake "${PROJECT_BINARY_DIR}/${PKG_NAME}ConfigVersion.cmake" @ONLY) install(FILES diff --git a/cmake/pkg-config.cmake b/src/haricot/cmake/pkg-config.cmake similarity index 100% rename from cmake/pkg-config.cmake rename to src/haricot/cmake/pkg-config.cmake diff --git a/cmake/python.cmake b/src/haricot/cmake/python.cmake similarity index 93% rename from cmake/python.cmake rename to src/haricot/cmake/python.cmake index d0d51ab..309c8a3 100644 --- a/cmake/python.cmake +++ b/src/haricot/cmake/python.cmake @@ -12,7 +12,7 @@ macro(SETUP_PYTHON_PKG) file(MAKE_DIRECTORY ${CMAKE_PYTHON_BUILD}/${PROJECT_NAME}) set(INIT_PKG_BUILD ${CMAKE_PYTHON_BUILD}/${PROJECT_NAME}/__init__.py) set(PYTHON_SOURCE_PATH "${PROJECT_SOURCE_DIR}/src") - configure_file(${ORIGIN}/cmake/__init__.py.in ${INIT_PKG_BUILD}) + configure_file(${ORIGIN}/__init__.py.in ${INIT_PKG_BUILD}) set(PATH_TO_${PROJECT_NAME}_PY_FILES "${PROJECT_SOURCE_DIR}/src/${PROJECT_NAME}") install(DIRECTORY ${PATH_TO_${PROJECT_NAME}_PY_FILES} DESTINATION lib/python3/dist-packages COMPONENT ${${PROJECT_NAME}_UPPER}) diff --git a/src/haricot/debian.cmake b/src/haricot/debian.cmake new file mode 100644 index 0000000..e945e68 --- /dev/null +++ b/src/haricot/debian.cmake @@ -0,0 +1,7 @@ +set(MAJOR_VERSION "0") +set(MINOR_VERSION "0") +set(PATCH_VERSION "1") +set(DESCRIPTION "haricot") +set(SUMMARY "haricot deb pkg") +set(VENDOR "beuzeboc") +set(MAINTAINER "guillaume.beuzeboc@gmail.com") diff --git a/configure b/src/haricot/haricot similarity index 100% rename from configure rename to src/haricot/haricot diff --git a/src/haricot/setup.zsh b/src/haricot/setup.zsh new file mode 100644 index 0000000..508f685 --- /dev/null +++ b/src/haricot/setup.zsh @@ -0,0 +1,3 @@ +CMAKE_PREFIX_PATH=/opt/haricot-pkgs:${CMAKE_PREFIX_PATH} +PYTHONPATH=/opt/haricot-pkgs/lib/python3/dist-packages:${PYTHONPATH} + diff --git a/setup_install.zsh b/src/haricot/setup_install.zsh similarity index 51% rename from setup_install.zsh rename to src/haricot/setup_install.zsh index 1b89afd..0647c33 100644 --- a/setup_install.zsh +++ b/src/haricot/setup_install.zsh @@ -1,3 +1,3 @@ MY_SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )" CMAKE_PREFIX_PATH=${MY_SCRIPTPATH}/install:${CMAKE_PREFIX_PATH} -PYTHONPATH=/home/beuzeboc/code/tmp/cmake_multi_repo_template/install/lib/python3/dist-packages:${PYTHONPATH} +PYTHONPATH=${MY_SCRIPTPATH}/install/lib/python3/dist-packages:${PYTHONPATH} diff --git a/src/haricot/setup_local.zsh b/src/haricot/setup_local.zsh new file mode 100644 index 0000000..78c3568 --- /dev/null +++ b/src/haricot/setup_local.zsh @@ -0,0 +1,3 @@ +MY_SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )" +CMAKE_PREFIX_PATH=${MY_SCRIPTPATH}/build/src:${CMAKE_PREFIX_PATH} +PYTHONPATH=${MY_SCRIPTPATH}/build/python/lib/python3.5/site-packages:${PYTHONPATH} diff --git a/src/z_lib/src/lib.cpp b/src/z_lib/src/lib.cpp index 88f49a1..34ac2ca 100644 --- a/src/z_lib/src/lib.cpp +++ b/src/z_lib/src/lib.cpp @@ -11,6 +11,7 @@ void libz_function() std::string s("2001-10-9"); //2001-October-09 date d(from_simple_string(s)); std::cout << to_simple_string(d) << std::endl; + std::cout << "this is z_lib" << std::endl; } catch(std::exception& e) { std::cout << " Exception: " << e.what() << std::endl;