diff --git a/CMakeLists.txt b/CMakeLists.txt index 82e5bf7..5171628 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -32,15 +32,6 @@ else () set(CMAKE_C_FLAGS_RELWITHDEBINFO_INIT "/MT /Zi /O2 /Ob1 /D NDEBUG") endif () -## Set installation directories for header files ### TODO: Clean this up... -if (IS_DIRECTORY ${INCLUDE_INSTALL_DIR}) - set(INCLUDE_INSTALL_DIR ${INCLUDE_INSTALL_DIR} CACHE PATH "Main include directory") - set(STLINK_INCLUDE_PATH "${INCLUDE_INSTALL_DIR}") -else () - set(INCLUDE_INSTALL_DIR "include" CACHE PATH "Main include directory") - set(STLINK_INCLUDE_PATH "${CMAKE_INSTALL_PREFIX}/${INCLUDE_INSTALL_DIR}") -endif () - ### # Dependencies @@ -94,12 +85,19 @@ include_directories(src) include_directories(src/st-flash) include_directories(src/stlink-lib) +## Set installation directory for header files +set(STLINK_INCLUDE_PATH ${CMAKE_INSTALL_INCLUDEDIR} CACHE PATH "Main include install directory") + +## Subordinate CMakeLists for version config & header installation +add_subdirectory(inc) + +## Define source- and headerfiles for stlink library set(STLINK_HEADERS inc/backend.h + inc/stlink.h src/stlink-lib/commands.h src/stlink-lib/libusb_settings.h src/stlink-lib/reg.h - inc/stlink.h src/stlink-lib/chipid.h src/stlink-lib/flash_loader.h src/stlink-lib/logging.h @@ -279,7 +277,6 @@ endif () # Additional build tasks ### -add_subdirectory(inc) # contains subordinate CMakeLists for version config add_subdirectory(src/stlink-gui) # contains subordinate CMakeLists to build GUI add_subdirectory(tests) # contains subordinate CMakeLists to build test executables add_subdirectory(cmake/packaging) # contains subordinate CMakeLists to build packages diff --git a/cmake/modules/get_version.cmake b/cmake/modules/get_version.cmake index dddb355..70fbde8 100644 --- a/cmake/modules/get_version.cmake +++ b/cmake/modules/get_version.cmake @@ -52,7 +52,7 @@ if (GIT_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git") # ...the version does not match with git-version string if (NOT __version_str STREQUAL __version_file) - message(STATUS "Rewrite ${PROJECT_SOURCE_DIR}/.version with ${__version_str}.") + message(STATUS "Rewrite ${PROJECT_SOURCE_DIR}/.version with ${__version_str}!") endif () else (NOT EXISTS "${PROJECT_SOURCE_DIR}/.version") diff --git a/cmake/packaging/cpack_config.cmake b/cmake/packaging/cpack_config.cmake index f36a50b..469e743 100644 --- a/cmake/packaging/cpack_config.cmake +++ b/cmake/packaging/cpack_config.cmake @@ -12,6 +12,7 @@ set(CPACK_PACKAGE_VENDOR "stlink-org") set(CMAKE_PROJECT_HOMEPAGE_URL "https://github.com/stlink-org/stlink") set(CPACK_SET_DESTDIR "ON") +file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/dist) set(CPACK_OUTPUT_FILE_PREFIX "${CMAKE_BINARY_DIR}/dist") if (APPLE) # macOS diff --git a/inc/CMakeLists.txt b/inc/CMakeLists.txt index 66af7e3..c816c70 100644 --- a/inc/CMakeLists.txt +++ b/inc/CMakeLists.txt @@ -3,7 +3,8 @@ configure_file( "${CMAKE_BINARY_DIR}/inc/version.h" ) -file(GLOB STLINK_HEADERS "src/st-link-lib/*.h" "${CMAKE_BINARY_DIR}/inc/version.h") +file(GLOB STLINK_HEADERS + "${CMAKE_SOURCE_DIR}/inc/*.h" + "${CMAKE_SOURCE_DIR}/src/stlink-lib/*.h" + "${CMAKE_BINARY_DIR}/inc/version.h") install(FILES ${STLINK_HEADERS} DESTINATION ${STLINK_INCLUDE_PATH}) -install(FILES ${CMAKE_SOURCE_DIR}/inc/stlink.h DESTINATION ${STLINK_INCLUDE_PATH}) -install(FILES ${CMAKE_SOURCE_DIR}/inc/stm32.h DESTINATION ${STLINK_INCLUDE_PATH})