Browse Source

Link to an external libiconv if available

This is required to compile on systems where the libc doesn't include
iconv such as OS X and presumably Windows.
pull/2/head
Daniel Scharrer 14 years ago
parent
commit
b110f3b742
  1. 36
      CMakeLists.txt
  2. 5
      README.md
  3. 45
      cmake/Findiconv.cmake

36
CMakeLists.txt

@ -2,8 +2,8 @@ project(InnoExtract)
cmake_minimum_required(VERSION 2.8)
# For custom cmake modules.
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
# Define configuration options
option(USE_LZMA "Build lzma decompression support." ON)
option(DEBUG_EXTRA "Expensive debug options" OFF)
@ -11,6 +11,11 @@ option(DEBUG_EXTRA "Expensive debug options" OFF)
set(MAN_DIR "share/man" CACHE STRING "Install location for man pages (relative to prefix).")
mark_as_advanced(MAN_DIR)
# Helper scrips
# For custom cmake modules.
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
include(CompileCheck)
include(VersionString)
include(CheckSymbolExists)
@ -19,6 +24,9 @@ include(StyleCheck)
include(Doxygen)
include(TestBigEndian)
# Find required libraries
# Force re-checking libraries if the compiler or compiler flags change.
if((NOT LAST_CMAKE_CXX_FLAGS STREQUAL CMAKE_CXX_FLAGS)
OR (NOT LAST_CMAKE_CXX_COMPILER STREQUAL CMAKE_CXX_COMPILER))
@ -55,6 +63,14 @@ list(APPEND LIBRARIES "${Boost_LIBRARIES}")
link_directories("${Boost_LIBRARY_DIRS}")
include_directories(SYSTEM "${Boost_INCLUDE_DIR}")
find_package(iconv REQUIRED)
list(APPEND LIBRARIES "${iconv_LIBRARIES}")
include_directories(SYSTEM "${iconv_INCLUDE_DIR}")
check_link_library(iconv iconv_LIBRARIES)
# Set compiler flags
if(${Boost_VERSION} LESS 104800)
# Older Boost versions don't work with C++11
else()
@ -92,14 +108,21 @@ else()
add_cxxflag("-Wno-unused-function")
endif()
# Because i'm lazy
# Link as few libraries as possible
# This is much easier than trying to decide which libraries are needed for each system
add_ldflag("-Wl,--as-needed")
# Check for optional functionality and system configuration
check_symbol_exists(isatty "unistd.h" HAVE_ISATTY)
check_symbol_exists(ioctl "sys/ioctl.h" HAVE_IOCTL)
test_big_endian(IS_BIG_ENDIAN)
# All sources:
set(INNOEXTRACT_SOURCES
src/cli/main.cpp
@ -160,6 +183,9 @@ file(GLOB_RECURSE ALL_INCLUDES "${CMAKE_SOURCE_DIR}/src/*.hpp")
list(SORT INNOEXTRACT_SOURCES)
list(SORT ALL_INCLUDES)
# Prepare generated files
include_directories(src ${CMAKE_CURRENT_BINARY_DIR})
configure_file("src/configure.hpp.in" "configure.hpp")
@ -168,6 +194,9 @@ set(VERSION_FILE "${CMAKE_BINARY_DIR}/version.cpp")
version_file("src/version.cpp.in" "${VERSION_FILE}" "VERSION" ".git")
list(APPEND INNOEXTRACT_SOURCES "${VERSION_FILE}")
# Main targets
add_executable(innoextract ${INNOEXTRACT_SOURCES} ${ALL_INCLUDES})
target_link_libraries(innoextract ${LIBRARIES})
@ -175,6 +204,7 @@ install(TARGETS innoextract RUNTIME DESTINATION bin)
install(FILES doc/innoextract.1 DESTINATION ${MAN_DIR}/man1 OPTIONAL)
# Additional targets.
add_style_check_target(style "${INNOEXTRACT_SOURCES}" "${ALL_INCLUDES}")

5
README.md

@ -15,14 +15,15 @@ Author: [Daniel Scharrer](http://constexpr.org/)
## Dependencies
* **Boost 1.37** or newer
* **[Boost](http://www.boost.org/) 1.37** or newer
* **liblzma** from [xz-utils](http://tukaani.org/xz/) *(optional)*
* **iconv** (either as part of the system libc, as is the case with [glibc](http://www.gnu.org/software/libc/), or as a separate [libiconv](http://www.gnu.org/software/libiconv/))
For Boost you will need the headers as well as the `iostreams`, `filesystem`, `date_time`, `system` and `program_options` libraries. Older Boost version may work but are not actively supported. The boost `iostreams` library needs to be build with zlib and bzip2 support.
While the liblzma dependency is optional, it is highly recommended and you won't be able to extract most installers created by newer Inno Setup versions without it.
To build innoextract you will also need **CMake 2.8** and a working C++ compiler, as well as the development headers for liblzma and boost.
To build innoextract you will also need **[CMake](http://cmake.org/) 2.8** and a working C++ compiler, as well as the development headers for liblzma and boost.
The website might have more [specific instructions for your Linux distribution](http://constexpr.org/innoextract/install).

45
cmake/Findiconv.cmake

@ -0,0 +1,45 @@
# Copyright (C) 2012 Daniel Scharrer
#
# This software is provided 'as-is', without any express or implied
# warranty. In no event will the author(s) be held liable for any damages
# arising from the use of this software.
#
# Permission is granted to anyone to use this software for any purpose,
# including commercial applications, and to alter it and redistribute it
# freely, subject to the following restrictions:
#
# 1. The origin of this software must not be misrepresented; you must not
# claim that you wrote the original software. If you use this software
# in a product, an acknowledgment in the product documentation would be
# appreciated but is not required.
# 2. Altered source versions must be plainly marked as such, and must not be
# misrepresented as being the original software.
# 3. This notice may not be removed or altered from any source distribution.
# Try to find the iconv library and include path for iconv.h.
# Once done this will define
#
# iconv_FOUND
# iconv_INCLUDE_DIR - where to find iconv.h
# iconv_LIBRARIES - libiconv.so or empty if none was found
# An empty iconv_LIBRARIES is not an error as iconv is often included in the system libc.
find_path(iconv_INCLUDE_DIR iconv.h DOC "The directory where iconv.h resides")
find_library(iconv_LIBRARY iconv DOC "The iconv library")
mark_as_advanced(iconv_INCLUDE_DIR)
mark_as_advanced(iconv_LIBRARY)
if(NOT iconv_LIBRARY)
set(iconv_LIBRARY)
endif()
# handle the QUIETLY and REQUIRED arguments and set iconv_FOUND to TRUE if
# all listed variables are TRUE
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(iconv DEFAULT_MSG iconv_INCLUDE_DIR)
if(iconv_FOUND)
set(iconv_LIBRARIES ${iconv_LIBRARY})
endif(iconv_FOUND)
Loading…
Cancel
Save