Skip to content

Commit

Permalink
Merge pull request #34 from lacc97/no-install-deps
Browse files Browse the repository at this point in the history
Make main dependencies private
  • Loading branch information
alandefreitas authored Sep 2, 2020
2 parents 4d19af6 + 162ce2a commit 9267985
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 36 deletions.
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,5 @@ if (MASTER_PROJECT)
${CMAKE_CURRENT_BINARY_DIR}/matplot++-config.cmake
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/Matplot++)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/matplot++-config.cmake
${CMAKE_CURRENT_SOURCE_DIR}/cmake/FindFilesystem.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/Matplot++)
endif()
6 changes: 0 additions & 6 deletions matplot++-config.cmake.in
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
include(CMakeFindDependencyMacro)

@PACKAGE_INIT@

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}")
find_dependency(Filesystem)
list(POP_BACK CMAKE_MODULE_PATH)

include("${CMAKE_CURRENT_LIST_DIR}/Matplot++Targets.cmake")

check_required_components(Matplot++)
37 changes: 9 additions & 28 deletions source/3rd_party/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
set(MATPLOT_DEPS_INCLUDE_DIR ${CMAKE_INSTALL_INCLUDEDIR}/matplot/deps)

# Add nodesoup library
if(WITH_SYSTEM_NODESOUP)
find_path(NODESOUP_INCLUDE_DIR nodesoup.hpp REQUIRED)
find_library(NODESOUP_LIB nodesoup REQUIRED)

add_library(nodesoup INTERFACE)
add_library(nodesoup INTERFACE IMPORTED GLOBAL)
target_include_directories(nodesoup INTERFACE ${NODESOUP_INCLUDE_DIR})
target_link_libraries(nodesoup INTERFACE ${NODESOUP_LIB})
else()
Expand All @@ -24,37 +22,28 @@ else()
set_target_properties(nodesoup PROPERTIES
CXX_VISIBILITY_PRESET "hidden")
target_include_directories(nodesoup
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/nodesoup/include>
$<INSTALL_INTERFACE:${MATPLOT_DEPS_INCLUDE_DIR}>)
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/nodesoup/include>)

# Hackfix to support MSVC standard library
# https://docs.microsoft.com/en-us/cpp/c-runtime-library/math-constants?view=vs-2019
target_compile_definitions(nodesoup PRIVATE _USE_MATH_DEFINES)

if(MASTER_PROJECT)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/nodesoup/include/nodesoup.hpp
DESTINATION ${MATPLOT_DEPS_INCLUDE_DIR})
# Install
if(MASTER_PROJECT AND NOT BUILD_SHARED_LIBS)
install(TARGETS nodesoup
EXPORT Matplot++Targets
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}/Matplot++)
endif()
endif()

# Add CImg library
add_library(cimg INTERFACE)
add_library(cimg INTERFACE IMPORTED GLOBAL)
if(WITH_SYSTEM_CIMG)
find_path(CIMG_INCLUDE_DIR CImg.h REQUIRED)

target_include_directories(cimg INTERFACE ${CIMG_INCLUDE_DIR})
else()
set(CIMG_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/cimg)

target_include_directories(cimg
INTERFACE $<BUILD_INTERFACE:${CIMG_INCLUDE_DIR}>
$<INSTALL_INTERFACE:${MATPLOT_DEPS_INCLUDE_DIR}>)

if(MASTER_PROJECT)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/cimg/CImg.h
DESTINATION ${MATPLOT_DEPS_INCLUDE_DIR})
endif()
endif()
target_include_directories(cimg INTERFACE ${CIMG_INCLUDE_DIR})


find_package(PkgConfig)
Expand Down Expand Up @@ -175,12 +164,4 @@ if(NOT WIN32)
else()
target_compile_definitions(cimg INTERFACE cimg_display=2)
target_link_libraries(cimg INTERFACE gdi32)
endif()

# Install
if(MASTER_PROJECT)
install(TARGETS nodesoup cimg
EXPORT Matplot++Targets
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/Matplot++
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}/Matplot++)
endif()
3 changes: 2 additions & 1 deletion source/matplot/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ add_library(matplot
target_include_directories(matplot
PUBLIC $<BUILD_INTERFACE:${MATPLOT_ROOT_DIR}/source>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
target_link_libraries(matplot PUBLIC nodesoup cimg std::filesystem)
target_link_libraries(matplot
PRIVATE cimg nodesoup std::filesystem)

# https://cmake.org/cmake/help/v3.14/manual/cmake-compile-features.7.html#requiring-language-standards
target_compile_features(matplot PUBLIC cxx_std_17)
Expand Down

0 comments on commit 9267985

Please sign in to comment.