Skip to content

Commit

Permalink
Add find_package support (#2)
Browse files Browse the repository at this point in the history
* add cmake find_package() support, to be tested.

* bugfix to  in mutilsConfig.cmake

* minor optimization; remove Makefile

* fix include and lib path
  • Loading branch information
songweijia authored and mpmilano committed Apr 7, 2019
1 parent e0433d7 commit 7072b25
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 26 deletions.
45 changes: 39 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,16 +1,49 @@
cmake_minimum_required (VERSION 3.1)
project (mutils)

#Versions
set(mutils_VERSION 1.0)

#CXX FLAGS
set(CMAKE_CXX_FLAGS_RELEASE "-std=c++14 -fPIC")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS_RELEASE}")
set(CMAKE_CXX_FLAGS_DEBUG "-std=c++14 -fPIC -g")
set(CMAKE_SHARED_LINKER_FLAGS "-shared --enable-new-dtags")

include_directories(${mutils_SOURCE_DIR}/include)

add_library(mutils SHARED utils.cpp abiutils.cpp)
target_include_directories(mutils PRIVATE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>)

#Make install
install(TARGETS mutils EXPORT mutils
LIBRARY DESTINATION lib)
install(DIRECTORY include/mutils
DESTINATION include)

include(CMakePackageConfigHelpers)
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/mutils/mutilsConfigVersion.cmake"
VERSION ${mutils_VERSION}
COMPATIBILITY AnyNewerVersion
)

export (EXPORT mutils
FILE "${CMAKE_CURRENT_BINARY_DIR}/mutils/mutilsTargets.cmake"
)

configure_file (mutilsConfig.cmake
"${CMAKE_CURRENT_BINARY_DIR}/mutils/mutilsConfig.cmake"
COPYONLY
)

set(ConfigPackageLocation lib/cmake/mutils)
install(EXPORT mutils
FILE mutilsTargets.cmake
DESTINATION ${ConfigPackageLocation}
)

set_target_properties(mutils PROPERTIES PUBLIC_HEADER "include/mutils/17_type_utils.hpp;include/mutils/17utils.hpp;include/mutils/AtScopeEnd.hpp;include/mutils/CTString.hpp;include/mutils/CTString_decl.hpp;include/mutils/CTString_impl.hpp;include/mutils/CTString_macro.hpp;include/mutils/CTString_split.hpp;include/mutils/CTString_strip_paren_group.hpp;include/mutils/FunctionalMap.hpp;include/mutils/Hertz.hpp;include/mutils/PrintableObject.hpp;include/mutils/abiutils.hpp;include/mutils/args-finder.hpp;include/mutils/argswrapper.hpp;include/mutils/as_value.hpp;include/mutils/backtrace.hpp;include/mutils/cexprutils.hpp;include/mutils/compile-time-lambda.hpp;include/mutils/compile-time-tuple.hpp;include/mutils/cstring.hpp;include/mutils/extras;include/mutils/filter-varargs.hpp;include/mutils/macro_utils.hpp;include/mutils/mutils.hpp;include/mutils/peano.hpp;include/mutils/private_access.hpp;include/mutils/restrict.hpp;include/mutils/tuple_extras.hpp;include/mutils/type_utils.hpp;include/mutils/typelist.hpp;include/mutils/typeset.hpp;include/mutils/variant.hpp")
install(TARGETS mutils
LIBRARY DESTINATION lib
PUBLIC_HEADER DESTINATION include/mutils/)
install(
FILES
mutilsConfig.cmake
"${CMAKE_CURRENT_BINARY_DIR}/mutils/mutilsConfigVersion.cmake"
DESTINATION ${ConfigPackageLocation}
)
20 changes: 0 additions & 20 deletions Makefile

This file was deleted.

2 changes: 2 additions & 0 deletions mutilsConfig.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
set(mutils_INCLUDE_DIRS "${CMAKE_INSTALL_PREFIX}/include")
set(mutils_LIBRARIES "-L${CMAKE_INSTALL_PREFIX}/lib -lmutils")

0 comments on commit 7072b25

Please sign in to comment.