--- CMakeLists.txt.orig +++ CMakeLists.txt @@ -18,18 +18,22 @@ set(CMAKE_INSTALL_PREFIX "/usr" CACHE PATH "default install path" FORCE) endif() -set(CMAKE_INSTALL_DOCDIR "" CACHE PATH "documentation root (DATAROOTDIR/doc/${PROJECT_NAME}${LIBIIO_VERSION_MAJOR}-doc)") include(GNUInstallDirs) if(ENABLE_SHARED AND ${CMAKE_SYSTEM_NAME} MATCHES "Linux") set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_FULL_LIBDIR}") set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) endif() -set(CMAKE_INSTALL_DOCDIR "${CMAKE_INSTALL_DATAROOTDIR}/doc/${PROJECT_NAME}${LIBIIO_VERSION_MAJOR}-doc") + +# Set the default install DOCDIR if not provided +if (NOT CMAKE_INSTALL_DOCDIR) + set (CMAKE_INSTALL_DOCDIR "${CMAKE_INSTALL_DATAROOTDIR}/doc/${PROJECT_NAME}${LIBIIO_VERSION_MAJOR}-doc") +endif () set(INSTALL_PKGCONFIG_DIR "${CMAKE_INSTALL_LIBDIR}/pkgconfig" CACHE PATH "Installation directory for pkgconfig (.pc) files") mark_as_advanced(INSTALL_PKGCONFIG_DIR) +# Set the default build type if not provided if (NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel." @@ -43,17 +47,24 @@ add_definitions(-DLIBIIO_STATIC=1) endif() -option(OSX_FRAMEWORK "Create a OSX_FRAMEWORK" ON) -if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin" AND OSX_FRAMEWORK) - option(OSX_PACKAGE "Create a OSX package" ON) +# Darwin-specific settings +if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") + option(OSX_FRAMEWORK "Create a OSX Framework" ON) + option(OSX_PACKAGE "Create a OSX Package" ON) - set(OSX_INSTALL_FRAMEWORKSDIR "/Library/Frameworks" CACHE STRING "Installation directory for frameworks") + # Set the default install location if not provided + if (NOT OSX_INSTALL_FRAMEWORKSDIR) + set (OSX_INSTALL_FRAMEWORKSDIR "/Library/Frameworks" CACHE STRING "Installation directory for frameworks") + endif () get_filename_component(OSX_INSTALL_FRAMEWORKSDIR "${OSX_INSTALL_FRAMEWORKSDIR}" REALPATH BASE_DIR "${CMAKE_BINARY_DIR}") set(CMAKE_MACOSX_RPATH ON) set(SKIP_INSTALL_ALL ${OSX_PACKAGE}) endif() +# set these before any external include directories +include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) + option(WITH_NETWORK_BACKEND "Enable the network backend" ON) option(WITH_TESTS "Build the test programs" ON) option(WITH_EXAMPLES "Build examples" OFF) @@ -317,8 +328,6 @@ include_directories(${LIBZSTD_INCLUDE_DIR}) endif (WITH_ZSTD) -include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) - if(WITH_NETWORK_BACKEND) if (WIN32) list(APPEND LIBS_TO_LINK wsock32 iphlpapi ws2_32)