Use "modern" CMake facilities to manage includes and libs
authorAlexey Sheplyakov <asheplyakov@altlinux.org>
Wed, 18 Dec 2019 10:52:17 +0000 (14:52 +0400)
committerAlexey Sheplyakov <asheplyakov@altlinux.org>
Fri, 28 Aug 2020 15:15:31 +0000 (19:15 +0400)
* Use target_link_libraries to specify dependencies (include paths,
  compiler options, etc)

* Export targets and provide `ginac-config.cmake` so the following
  `CMakeLists.txt` is enough to build a program using GiNaC:

    cmake_minimum_required(VERSION 3.1)
    project(foo)
    find_package(ginac REQUIRED)
    add_executable(foo foo.cpp)
    target_link_libraries(foo PRIVATE ginac::ginac)

* GiNaC can be included as a (CMake) subproject. One can put GiNaC
  sources (either from git or a tarball) into a subdirectory (say,
  `ginac`) and use the following CMakeLists.txt to build everything:

    cmake_minimum_required(VERSION 3.1)
    project(foo)
    add_subdirectory(ginac)
    add_executable(foo foo.cpp)
    target_link_libraries(foo PRIVATE ginac::ginac)

CMakeLists.txt
Makefile.am
check/CMakeLists.txt
cmake/ginac-config.cmake.in [new file with mode: 0644]
cmake/modules/FindCLN.cmake
doc/examples/CMakeLists.txt
ginac.pc.cmake
ginac/CMakeLists.txt
ginsh/CMakeLists.txt
tools/CMakeLists.txt

index 20ce8e1906cb7e39ac14ba003495928091224263..aa221ff7059148c8fafb227dcc0231799623e887 100644 (file)
@@ -1,15 +1,15 @@
 cmake_minimum_required(VERSION 3.1)
-set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules")
+set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")
 
 project(GiNaC)
-file(STRINGS ${CMAKE_SOURCE_DIR}/ginac/version.h _ginac_vinfo REGEX "^#define[\t ]+GINACLIB_.*_VERSION.*")
+file(STRINGS ${CMAKE_CURRENT_SOURCE_DIR}/ginac/version.h _ginac_vinfo REGEX "^#define[\t ]+GINACLIB_.*_VERSION.*")
 string(REGEX REPLACE "^.*GINACLIB_MAJOR_VERSION[ \t]+([0-9]+).*" "\\1" GINAC_MAJOR_VERSION "${_ginac_vinfo}")
 string(REGEX REPLACE "^.*GINACLIB_MINOR_VERSION[ \t]+([0-9]+).*" "\\1" GINAC_MINOR_VERSION "${_ginac_vinfo}")
 string(REGEX REPLACE "^.*GINACLIB_MICRO_VERSION[ \t]+([0-9]+).*" "\\1" GINAC_MICRO_VERSION "${_ginac_vinfo}")
 set(GINAC_VERSION "${GINAC_MAJOR_VERSION}.${GINAC_MINOR_VERSION}.${GINAC_MICRO_VERSION}")
 
 # Library versioning info
-file(STRINGS ${CMAKE_SOURCE_DIR}/ginac/version.h _ginac_vinfo REGEX "^#define[\t ]+GINAC_LT_.*")
+file(STRINGS ${CMAKE_CURRENT_SOURCE_DIR}/ginac/version.h _ginac_vinfo REGEX "^#define[\t ]+GINAC_LT_.*")
 string(REGEX REPLACE "^.*GINAC_LT_CURRENT[ \t]+([0-9]+).*" "\\1" ginac_lt_current "${_ginac_vinfo}")
 string(REGEX REPLACE "^.*GINAC_LT_AGE[ \t]+([0-9]+).*" "\\1" ginac_lt_age "${_ginac_vinfo}")
 string(REGEX REPLACE "^.*GINAC_LT_REVISION[ \t]+([0-9]+).*" "\\1" ginac_lt_revision "${_ginac_vinfo}")
@@ -17,71 +17,39 @@ string(REGEX REPLACE "^.*GINAC_LT_REVISION[ \t]+([0-9]+).*" "\\1" ginac_lt_revis
 math(EXPR ginaclib_soversion "${ginac_lt_current} - ${ginac_lt_age}")
 set(ginaclib_version ${ginaclib_soversion}.${ginac_lt_age}.${ginac_lt_revision})
 
+include(GNUInstallDirs)
+
 # make check
 enable_testing()
-add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND})
-add_custom_target(test_suite)
+if (NOT TARGET check)
+       add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND})
+endif()
+if (NOT TARGET test_suite)
+       add_custom_target(test_suite)
+endif()
 if (WIN32)
        if (NOT DEFINED CMAKE_RUNTIME_OUTPUT_DIRECTORY)
                set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin)
        endif()
 endif()
 # make info
-add_custom_target(info ALL)
-add_custom_target(html)
-add_custom_target(pdf)
+if (NOT TARGET info)
+       add_custom_target(info ALL)
+endif()
+if (NOT TARGET html)
+       add_custom_target(html)
+endif()
+if (NOT TARGET pdf)
+       add_custom_target(pdf)
+endif()
 
 set (CMAKE_CXX_STANDARD 11)
 
 find_package(CLN 1.2.2 REQUIRED)
-include_directories(${CLN_INCLUDE_DIR})
 
 include(CheckIncludeFile)
 check_include_file("unistd.h" HAVE_UNISTD_H)
 
-include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}/ginac)
-
-# This macro implements some very special logic how to deal with the cache.
-# By default the various install locations inherit their value from their
-#"parent" variable, so if you set CMAKE_INSTALL_PREFIX, then
-# EXEC_INSTALL_PREFIX, BIN_INSTALL_DIR, LIB_INSTALL_DIR, etc will calculate
-# their value by appending subdirs to CMAKE_INSTALL_PREFIX.
-# This would work just fine without using the cache.
-# But if somebody wants e.g. a different EXEC_INSTALL_PREFIX this value
-# has to go into the cache, otherwise it will be forgotten on the next cmake
-# run. Once a variable is in the cache, it doesn't depend on its "parent"
-# variables anymore and you can only change it by editing it directly.
-# This macro helps in this regard, because as long as you don't set one
-# of the variables explicitly to some location, the value will be computed
-# from parents of the variable in question. So modifying CMAKE_INSTALL_PREFIX
-# later on will have the desired effect.
-# But once you decide to set e.g. EXEC_INSTALL_PREFIX to some special
-# location this will go into the cache and it will no longer depend on
-# CMAKE_INSTALL_PREFIX.
-
-macro(_set_fancy _var _value _comment)
-       set(predefinedvalue "${_value}")
-       if ("${CMAKE_INSTALL_PREFIX}" STREQUAL "${GINAC_INSTALL_DIR}" AND DEFINED GINAC_${_var})
-               set(predefinedvalue "${GINAC_${_var}}")
-       endif()
-       if (NOT DEFINED ${_var})
-               set(${_var} ${predefinedvalue})
-       else()
-               set(${_var} "${${_var}}" CACHE PATH "${_comment}")
-       endif()
-endmacro(_set_fancy)
-
-_set_fancy(EXEC_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}"
-          "Base directory for libraries and executables")
-_set_fancy(LIB_INSTALL_DIR "${EXEC_INSTALL_PREFIX}/lib"
-          "Libraries installation directory")
-_set_fancy(BIN_INSTALL_DIR "${EXEC_INSTALL_PREFIX}/bin"
-          "Binaries installation directory")
-_set_fancy(SHARE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}/share"
-          "Base directory for architecture independent files")
-_set_fancy(INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/include"
-          "Headers installation directory")
-
 if (NOT DEFINED BUILD_SHARED_LIBS)
        if (NOT MSVC)
                set(BUILD_SHARED_LIBS true)
@@ -105,7 +73,7 @@ set(_wl_rpath "${CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG}")
 
 # rpath for the pkg-config meta-data.
 set(_ginaclib_rpath "${_wl_rpath}${_ginac_rpath_reloc}")
-list(FIND CMAKE_CXX_IMPLICIT_LINK_DIRECTORIES "${LIB_INSTALL_DIR}" isSystemDir)
+list(FIND CMAKE_CXX_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_FULL_LIBDIR}" isSystemDir)
 if ("${isSystemDir}" STREQUAL "-1")
        list(APPEND _ginaclib_rpath "${_wl_rpath}\${libdir}")
 endif()
@@ -116,12 +84,12 @@ if (NOT CMAKE_SKIP_RPATH)
        endif()
 endif()
 
-configure_file(${CMAKE_SOURCE_DIR}/ginac.pc.cmake ${CMAKE_BINARY_DIR}/ginac.pc @ONLY)
-install(FILES ${CMAKE_BINARY_DIR}/ginac.pc DESTINATION "${LIB_INSTALL_DIR}/pkgconfig")
+configure_file(${CMAKE_CURRENT_SOURCE_DIR}/ginac.pc.cmake ${CMAKE_CURRENT_BINARY_DIR}/ginac.pc @ONLY)
+install(FILES ${CMAKE_CURRENT_BINARY_DIR}/ginac.pc DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
 
 # rpath for libginac.so itself, ginsh, and friends
 set(_ginac_rpath ${_ginac_rpath_reloc})
-foreach(_d ${CLN_LIBRARY_DIRS} ${LIB_INSTALL_DIR})
+foreach(_d ${CLN_LIBRARY_DIRS} ${CMAKE_INSTALL_FULL_LIBDIR})
        list(FIND CMAKE_CXX_IMPLICIT_LINK_DIRECTORIES "${_d}" isSystemDir)
        if ("${isSystemDir}" STREQUAL "-1")
                list(APPEND _ginac_rpath "${_d}")
@@ -137,16 +105,16 @@ if (NOT DEFINED CMAKE_INSTALL_RPATH)
        set(CMAKE_INSTALL_RPATH ${ginac_rpath})
 endif()
 if (APPLE AND NOT DEFINED CMAKE_INSTALL_NAME_DIR)
-       set(CMAKE_INSTALL_NAME_DIR ${LIB_INSTALL_DIR})
+       set(CMAKE_INSTALL_NAME_DIR ${CMAKE_INSTALL_FULL_LIBDIR})
 endif()
 
-list(FIND CMAKE_CXX_IMPLICIT_LINK_DIRECTORIES "${LIB_INSTALL_DIR}" isSystemDir)
+list(FIND CMAKE_CXX_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_FULL_LIBDIR}" isSystemDir)
 if ("${isSystemDir}" STREQUAL "-1")
        string(REPLACE ":" ";" _install_rpath "${CMAKE_INSTALL_RPATH}")
-       list(FIND _install_rpath "${LIB_INSTALL_DIR}" _is_rpath_consistent)
+       list(FIND _install_rpath "${CMAKE_INSTALL_FULL_LIBDIR}" _is_rpath_consistent)
        if ("${_is_rpath_consistent}" STREQUAL "-1")
                message(WARNING "the libginac.so library will be installed into "
-                               "a non-standard directory (${LIB_INSTALL_DIR}), "
+                       "a non-standard directory (${CMAKE_INSTALL_FULL_LIBDIR}), "
                                "however, the rpath (${_install_rpath}) "
                                "does not contain that directory. Most likely "
                                "things won't work without extra configuration "
@@ -154,6 +122,23 @@ if ("${isSystemDir}" STREQUAL "-1")
        endif()
 endif()
 
+include(CMakePackageConfigHelpers)
+write_basic_package_version_file(
+       ${CMAKE_CURRENT_BINARY_DIR}/ginac-config-version.cmake
+       VERSION ${GINAC_VERSION}
+       COMPATIBILITY AnyNewerVersion
+)
+
+configure_package_config_file(${CMAKE_CURRENT_LIST_DIR}/cmake/ginac-config.cmake.in
+       ${CMAKE_CURRENT_BINARY_DIR}/ginac-config.cmake
+       INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/ginac
+)
+
+install(FILES
+       ${CMAKE_CURRENT_BINARY_DIR}/ginac-config.cmake
+       ${CMAKE_CURRENT_BINARY_DIR}/ginac-config-version.cmake
+       DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/ginac
+)
 
 include(FindFLEX)
 include(FindBISON)
@@ -183,7 +168,6 @@ endif()
 
 
 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/config.h)
-add_definitions(-DHAVE_CONFIG_H)
 
 if (NOT LIBEXECDIR)
        set (LIBEXECDIR "${CMAKE_INSTALL_PREFIX}/libexec")
index b651383cf687c7f29ab03475d1b4ff0853352453..950d12d5365a00c175991d20f3fb141dc1b1d418 100644 (file)
@@ -11,6 +11,7 @@ CMAKE_FILES = CMakeLists.txt \
              ginac.pc.cmake \
              config.cmake.in \
              INSTALL.CMake \
+             cmake/ginac-config.cmake.in \
              cmake/modules/FindCLN.cmake \
              cmake/modules/FindReadline.cmake \
              cmake/modules/FindGiNaC.cmake \
index 544c412e976f202f8abbb098a8231d447a95986f..caabbfc3240beb27d45e3b8f784091f673537bc6 100644 (file)
@@ -1,5 +1,3 @@
-include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../ginac)
-add_definitions(-DIN_GINAC)
 
 set(ginac_tests
        check_numeric
@@ -70,7 +68,7 @@ macro(add_ginac_test thename)
                set(${thename}_sources ${thename}.cpp ${${thename}_extra_src})
        endif()
        add_executable(${thename} EXCLUDE_FROM_ALL ${${thename}_sources})
-       target_link_libraries(${thename} ginac ${LIBDL_LIBRARIES})
+       target_link_libraries(${thename} ginac::ginac)
        add_dependencies(test_suite ${thename})
        add_dependencies(check ${thename})
        add_test(NAME ${thename} COMMAND $<TARGET_FILE:${thename}>)
@@ -79,6 +77,7 @@ endmacro()
 macro(add_ginac_timing thename)
        set(${thename}_extra_src timer.cpp randomize_serials.cpp)
        add_ginac_test(${thename})
+       target_compile_definitions(${thename} PRIVATE HAVE_CONFIG_H)
 endmacro()
 
 set(check_matrices_extra_src genex.cpp)
diff --git a/cmake/ginac-config.cmake.in b/cmake/ginac-config.cmake.in
new file mode 100644 (file)
index 0000000..ba6e5b3
--- /dev/null
@@ -0,0 +1,9 @@
+get_filename_component(ginac_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
+include(CMakeFindDependencyMacro)
+find_package(CLN 1.2.2 REQUIRED)
+
+if (NOT TARGET ginac::ginac)
+       include("${ginac_CMAKE_DIR}/ginac-targets.cmake")
+endif()
+
+set(ginac_LIBRARIES ginac::ginac)
index ee5fc5ca628206542d69d87b920e6c5e0f4bd760..1f07bc9ab0a138a067ecaf841445e3ccbc92bf56 100644 (file)
@@ -116,3 +116,26 @@ include(FindPackageHandleStandardArgs)
 FIND_PACKAGE_HANDLE_STANDARD_ARGS(CLN REQUIRED_VARS CLN_LIBRARIES CLN_INCLUDE_DIR
                                      VERSION_VAR CLN_VERSION)
 
+if (CLN_FOUND AND NOT TARGET cln::cln)
+       set(_found_shared_libcln FALSE)
+       get_filename_component(_libcln_suffix ${CLN_LIBRARIES} EXT)
+       if (_libcln_suffix STREQUAL ${CMAKE_STATIC_LIBRARY_SUFFIX})
+               # XXX: msvc uses the same suffix for both static and import libraries
+               add_library(cln::cln STATIC IMPORTED)
+       else()
+               set(_found_shared_libcln TRUE)
+               add_library(cln::cln SHARED IMPORTED)
+       endif()
+       set_target_properties(cln::cln PROPERTIES
+               INTERFACE_INCLUDE_DIRECTORIES ${CLN_INCLUDE_DIR}
+       )
+       if (WIN32 AND _found_shared_libcln)
+               set_target_properties(cln::cln PROPERTIES
+                       IMPORTED_IMPLIB ${CLN_LIBRARIES}
+               )
+       else()
+               set_target_properties(cln::cln PROPERTIES
+                       IMPORTED_LOCATION ${CLN_LIBRARIES}
+               )
+       endif()
+endif()
index afdc67d206fcb65dea2ee633925fb12b67bc6822..ea5f64d7619f39d74a93e4b82d069bb4d8fc7d54 100644 (file)
@@ -1,23 +1,34 @@
-add_info_file(ginac-examples)
+cmake_minimum_required(VERSION 3.1)
 
-add_definitions(-DIN_GINAC)
-include_directories(${CMAKE_SOURCE_DIR}/ginac ${CMAKE_BUILD_DIR}/ginac)
+project(GiNaC_examples)
+
+if (TARGET ginac)
+       add_info_file(ginac-examples)
+endif()
+
+if (NOT TARGET ginac AND EXISTS ${CMAKE_CURRENT_LIST_DIR}/ginac/CMakeLists.txt)
+       add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/ginac ${CMAKE_CURRENT_BINARY_DIR}/ginac)
+endif()
+
+if (NOT TARGET ginac)
+       find_package(ginac REQUIRED 1.7.0)
+endif()
 
 add_executable(archive1 archive1.cpp)
-target_link_libraries(archive1 ginac ${LIBDL_LIBRARIES})
+target_link_libraries(archive1 ginac::ginac)
 
 add_executable(compile1 compile1.cpp)
-target_link_libraries(compile1 ginac ${LIBDL_LIBRARIES})
+target_link_libraries(compile1 ginac::ginac)
 
 # XXX: compile2 example uses the Cuba library (http://www.feynarts.de/cuba)
 # add_executable(compile2 compile2.cpp)
-# target_link_libraries(compile2 ginac ${LIBDL_LIBRARIES})
+# target_link_libraries(compile2 ginac::ginac)
 
 add_executable(compile3 compile3.cpp)
-target_link_libraries(compile3 ginac ${LIBDL_LIBRARIES})
+target_link_libraries(compile3 ginac::ginac)
 
 add_executable(mystring mystring.cpp)
-target_link_libraries(mystring ginac ${LIBDL_LIBRARIES})
+target_link_libraries(mystring ginac::ginac)
 
 add_executable(derivative derivative.cpp)
-target_link_libraries(derivative ginac ${LIBDL_LIBRARIES})
+target_link_libraries(derivative ginac::ginac)
index 4b168beaefe53566acdc33fdd72bb363b246336d..18543ecf2c49b696eb1a364d0e1275bfa40a7767 100644 (file)
@@ -1,7 +1,7 @@
 prefix=@CMAKE_INSTALL_PREFIX@
-exec_prefix=@EXEC_INSTALL_PREFIX@
-libdir=@LIB_INSTALL_DIR@
-includedir=@INCLUDE_INSTALL_DIR@
+exec_prefix=@CMAKE_INSTALL_PREFIX@
+libdir=@CMAKE_INSTALL_FULL_LIBDIR@
+includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@
 
 Name: GiNaC
 Description: C++ library for symbolic calculations
index 98bd89b80fec372b4518480cff0dc19a9b8b9145..086665511c974f92d12a1151b0cf745b57ee4f04 100644 (file)
@@ -1,4 +1,3 @@
-cmake_minimum_required(VERSION 2.6)
 
 set(ginaclib_sources
     add.cpp
@@ -147,12 +146,21 @@ set(ginaclib_private_headers
 )
 
 add_library(ginac ${ginaclib_sources})
-add_definitions(-DLIBEXECDIR="${LIBEXECDIR}/")
+add_library(ginac::ginac ALIAS ginac)
 set_target_properties(ginac PROPERTIES
        SOVERSION ${ginaclib_soversion}
        VERSION ${ginaclib_version})
-target_link_libraries(ginac ${CLN_LIBRARIES})
-include_directories(${CMAKE_SOURCE_DIR}/ginac)
+target_compile_definitions(ginac
+       PUBLIC $<BUILD_INTERFACE:IN_GINAC>
+       PRIVATE -DLIBEXECDIR="${LIBEXECDIR}/" HAVE_CONFIG_H
+)
+target_link_libraries(ginac PUBLIC cln::cln ${LIBDL_LIBRARIES})
+target_include_directories(ginac PUBLIC
+       $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
+       $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
+       $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/..>
+       $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
+)
 
 if (WIN32 AND CMAKE_COMPILER_IS_GNUCXX AND BUILD_SHARED_LIBS)
        set_target_properties(ginac PROPERTIES
@@ -167,10 +175,18 @@ if (NOT BUILD_SHARED_LIBS)
        set_target_properties(ginac PROPERTIES PREFIX "lib")
 endif()
 
-install(TARGETS ginac LIBRARY DESTINATION "${LIB_INSTALL_DIR}"
-                     RUNTIME DESTINATION "${BIN_INSTALL_DIR}"
-                     ARCHIVE DESTINATION "${LIB_INSTALL_DIR}")
-install(FILES ${ginaclib_public_headers} DESTINATION "${INCLUDE_INSTALL_DIR}/ginac")
+install(TARGETS ginac
+                     EXPORT ginac-exports
+                     LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
+                     RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
+                     ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
+)
+install(FILES ${ginaclib_public_headers} DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/ginac")
+install(EXPORT ginac-exports
+       FILE ginac-targets.cmake
+       NAMESPACE ginac::
+       DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/ginac
+)
 
 add_custom_command(
        OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/function.h
index 46de38bff386820f0ee32b56a377b34e650073e6..d90dd8e13c6ee5922aa857aee98f7b6d774a98fe 100644 (file)
@@ -1,9 +1,3 @@
-include_directories(
-       ${CMAKE_CURRENT_SOURCE_DIR}/../ginac
-       ${CMAKE_CURRENT_BINARY_DIR}/../ginac
-       ${CMAKE_CURRENT_SOURCE_DIR}
-       ${CMAKE_CURRENT_BINARY_DIR})
-add_definitions(-DIN_GINAC)
 
 bison_target(ginsh_parser
              ginsh_parser.ypp
@@ -34,8 +28,9 @@ set(ginsh_DISTRIB
     ginsh_fcn_help.py
     ginsh_op_help.py
 )
+set(ginsh_include_directories ${CMAKE_CURRENT_BINARY_DIR}/.. ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
 if (READLINE_FOUND)
-       include_directories(${READLINE_INCLUDE_DIRS})
+       set(ginsh_include_directories ${ginsh_include_directories} ${READLINE_INCLUDE_DIRS})
 endif()
 
 add_custom_command(
@@ -61,5 +56,7 @@ if (READLINE_FOUND)
 endif()
 
 add_executable(ginsh ${ginsh_SOURCES} ${ginsh_HEADERS})
-target_link_libraries(ginsh ginac ${ginsh_extra_libs} ${LIBDL_LIBRARIES})
-install(TARGETS ginsh RUNTIME DESTINATION "${BIN_INSTALL_DIR}")
+target_link_libraries(ginsh ginac::ginac ${ginsh_extra_libs})
+target_include_directories(ginsh PRIVATE ${ginsh_include_directories})
+target_compile_definitions(ginsh PRIVATE HAVE_CONFIG_H)
+install(TARGETS ginsh RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
index f444dcfe74bc94ef5a84b18b0ffb21ca5b0e3f6d..0c787ce65bdef88522ef660edf55ea57dc0b5b84 100644 (file)
@@ -1,9 +1,7 @@
-include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../ginac)
-add_definitions(-DIN_GINAC)
 
 add_executable(viewgar viewgar.cpp)
-target_link_libraries(viewgar ginac ${LIBDL_LIBRARIES})
-install(TARGETS viewgar RUNTIME DESTINATION "${BIN_INSTALL_DIR}")
+target_link_libraries(viewgar ginac::ginac)
+install(TARGETS viewgar RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
 
 if (CMAKE_COMPILER_IS_GNUCC)
        set (CC gcc)
@@ -12,5 +10,5 @@ if (CMAKE_COMPILER_IS_GNUCC)
           "${CMAKE_CURRENT_BINARY_DIR}/ginac-excompiler"
        )
 
-       install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/ginac-excompiler DESTINATION "${LIBEXECDIR}")
+       install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/ginac-excompiler DESTINATION "${CMAKE_INSTALL_LIBEXECDIR}")
 endif (CMAKE_COMPILER_IS_GNUCC)