From 3f1845331293662f6c209fab444573c8bdab0dc9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Av=C3=A9?= Date: Thu, 26 Jan 2017 15:47:58 +0100 Subject: [PATCH] Properly install the project --- CMakeLists.txt | 6 ++++-- LexesisConfig.cmake | 5 +++++ README.md | 9 ++++----- src/CMakeLists.txt | 3 ++- 4 files changed, 15 insertions(+), 8 deletions(-) create mode 100644 LexesisConfig.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 6caef7a..13ad5f2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -45,8 +45,6 @@ if(DOXYGEN_FOUND) add_custom_target(doc ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMENT "Generating API documentation" VERBATIM) endif(DOXYGEN_FOUND) -set(CMAKE_INSTALL_PREFIX "${CMAKE_CURRENT_BINARY_DIR}") - include_directories(include) add_subdirectory(src) add_dependencies(Lexesis ext-optparse) @@ -59,3 +57,7 @@ install(DIRECTORY include/Lexesis DESTINATION include) add_subdirectory(examples) + +install(EXPORT LexesisTargets DESTINATION lib/cmake/Lexesis) +install(FILES LexesisConfig.cmake DESTINATION lib/cmake/Lexesis) +install(DIRECTORY man/man1 man/man5 DESTINATION man) diff --git a/LexesisConfig.cmake b/LexesisConfig.cmake new file mode 100644 index 0000000..9e8d97f --- /dev/null +++ b/LexesisConfig.cmake @@ -0,0 +1,5 @@ +get_filename_component(SELF_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH) +include(${SELF_DIR}/LexesisTargets.cmake) +get_filename_component(LEXESIS_INCLUDE_DIRS "${SELF_DIR}/../../../include/" ABSOLUTE) +get_filename_component(LEXESIS_EXE "${SELF_DIR}/../../../bin/Lexesis" ABSOLUTE) +set(LEXESIS_FOUND TRUE) diff --git a/README.md b/README.md index add0555..b004a82 100644 --- a/README.md +++ b/README.md @@ -50,10 +50,9 @@ Get your terminal in the source tree and run the following commands: cd build cmake .. make - make install + sudo make install -This will place the Lexesis executable in the `build/bin` folder, with some extra needed data for Lexesis in `build/share` -You can now simply run `./bin/Lexesis` with the arguments you like (see below and in the man pages for an overview). +You can now run `Lexesis` If you want to build the documentation as well, simply run @@ -64,9 +63,9 @@ The output should be located in `build/doc`, with the main *html* page in `build ### Running tests First, build Lexesis in debug mode. The first difference with the normal building, is the line where you call cmake. That line should read - cmake .. -DCMAKE_BUILD_TYPE=Debug + cmake .. -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=. -instead. Afterwards, after calling `make install`, build all the examples as well with +instead. Afterwards, after calling `make install` (which now install locally in the build folder, so you don't need the sudo), build all the examples as well with cmake . make examples diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 1691921..38c0c15 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -39,8 +39,9 @@ if (CMAKE_BUILD_TYPE MATCHES Debug) target_link_libraries(Lexesis-test Lexesis-backends lxs templ lxsinput mstch::mstch) endif() -install(TARGETS Lexesis templ lxs Lexesis-backends lxsinput +install(TARGETS Lexesis templ lxs Lexesis-backends lxsinput EXPORT LexesisTargets RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib + INCLUDES DESTINATION include )