Skip to content

Commit

Permalink
Merge pull request #33 from imciner2/im/cmakefix
Browse files Browse the repository at this point in the history
Include version information in CMake and the program
  • Loading branch information
gbanjac committed Oct 29, 2020
2 parents 6a8a387 + 634fd4b commit a00d500
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 2 deletions.
21 changes: 19 additions & 2 deletions CMakeLists.txt
@@ -1,8 +1,14 @@
# Minimum version required
cmake_minimum_required (VERSION 3.2)

set(QDLDL_VERSION_MAJOR "0")
set(QDLDL_VERSION_MINOR "1")
set(QDLDL_VERSION_PATCH "6")
set(QDLDL_VERSION "${QDLDL_VERSION_MAJOR}.${QDLDL_VERSION_MINOR}.${QDLDL_VERSION_PATCH}")

# Project name
project (qdldl)
project(qdldl VERSION ${QDLDL_VERSION})


# Set the output folder where your program will be created
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/out)
Expand Down Expand Up @@ -76,6 +82,10 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/configure/qdldl_types.h.in
${CMAKE_CURRENT_SOURCE_DIR}/include/qdldl_types.h
NEWLINE_STYLE LF)

configure_file(${CMAKE_CURRENT_SOURCE_DIR}/configure/qdldl_version.h.in
${CMAKE_CURRENT_SOURCE_DIR}/include/qdldl_version.h
NEWLINE_STYLE LF)


# Set sources
# ----------------------------------------------
Expand All @@ -88,6 +98,7 @@ set(
qdldl_headers
include/qdldl.h
include/qdldl_types.h
include/qdldl_version.h
)

# Create object library
Expand Down Expand Up @@ -152,6 +163,11 @@ target_link_libraries (qdldl_example qdldlstatic)
# ----------------------------------------------
include(CMakePackageConfigHelpers)

write_basic_package_version_file("${CMAKE_CURRENT_BINARY_DIR}/qdldl-config-version.cmake"
VERSION ${QDLDL_VERSION}
COMPATIBILITY SameMajorVersion
)

export(EXPORT ${PROJECT_NAME}
FILE "${CMAKE_CURRENT_BINARY_DIR}/qdldl-targets.cmake"
NAMESPACE qdldl::)
Expand All @@ -164,14 +180,15 @@ endif()
# Create CMake packages for the install directory
# ----------------------------------------------

set(ConfigPackageLocation lib/cmake/qdldl)
set(ConfigPackageLocation ${CMAKE_INSTALL_LIBDIR}/cmake/qdldl)

install(EXPORT ${PROJECT_NAME}
FILE qdldl-targets.cmake
NAMESPACE qdldl::
DESTINATION ${ConfigPackageLocation})

install(FILES ${CMAKE_CURRENT_BINARY_DIR}/qdldl-config.cmake
${CMAKE_CURRENT_BINARY_DIR}/qdldl-config-version.cmake
DESTINATION ${ConfigPackageLocation})


Expand Down
8 changes: 8 additions & 0 deletions configure/qdldl_version.h.in
@@ -0,0 +1,8 @@
#ifndef QDLDL_VERSION_H_
#define QDLDL_VERSION_H_

#define QDLDL_VERSION_MAJOR @QDLDL_VERSION_MAJOR@
#define QDLDL_VERSION_MINOR @QDLDL_VERSION_MINOR@
#define QDLDL_VERSION_PATCH @QDLDL_VERSION_PATCH@

#endif // #ifndef QDLDL_VERSION_H_
1 change: 1 addition & 0 deletions include/.gitignore
@@ -1 +1,2 @@
qdldl_types.h
qdldl_version.h
1 change: 1 addition & 0 deletions include/qdldl.h
Expand Up @@ -3,6 +3,7 @@

// Include qdldl type options
#include "qdldl_types.h"
#include "qdldl_version.h"

# ifdef __cplusplus
extern "C" {
Expand Down

0 comments on commit a00d500

Please sign in to comment.