Skip to content

Commit

Permalink
Add CMake build system.
Browse files Browse the repository at this point in the history
  • Loading branch information
LebedevRI committed Dec 23, 2016
1 parent fa23d1c commit 11f079c
Show file tree
Hide file tree
Showing 11 changed files with 474 additions and 1,323 deletions.
8 changes: 3 additions & 5 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,10 @@
*.h text
*.xml text
*.xsl text
*.xsd text
*.md text
*.txt text

# Declare files that will always have CRLF line endings on checkout.
*.sln text eol=crlf
*.vcproj text eol=crlf
*.cmake text

# Denote all files that are truly binary and should not be modified.
*.lib binary
*.lib binary
15 changes: 15 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
# cmake out-of-source build tree
build*/

# tmp files
*~
.DS_Store
cscope.out
.*.swp

# project files
*.kdev4
*.sln
*.vcproj
*.vcxproj

# Compiled Object files
*.slo
*.lo
Expand Down
29 changes: 29 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
cmake_minimum_required(VERSION 3.0)

cmake_policy(SET CMP0011 NEW)
cmake_policy(SET CMP0025 NEW)

# Avoid source tree pollution
set(CMAKE_DISABLE_SOURCE_CHANGES ON)
set(CMAKE_DISABLE_IN_SOURCE_BUILD ON)

If(CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR)
message(FATAL_ERROR "In-source builds are not permitted. Make a separate folder for building:\nmkdir build; cd build; cmake ..\nBefore that, remove the files already created:\nrm -rf CMakeCache.txt CMakeFiles")
endif(CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR)

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")

include(GNUInstallDirs)

project(rawspeed CXX)

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

option(USE_XMLLINT "Run xmllint to test if data/cameras.xml is valid" ON)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")

add_subdirectory(RawSpeed)
add_subdirectory(data)
28 changes: 0 additions & 28 deletions RawSpeed.sln

This file was deleted.

105 changes: 105 additions & 0 deletions RawSpeed/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
find_package(Pugixml 1.2 REQUIRED)
include_directories(SYSTEM ${Pugixml_INCLUDE_DIRS})

find_package(JPEG REQUIRED)
include_directories(SYSTEM ${JPEG_INCLUDE_DIRS})

FILE(GLOB RAWSPEED_SOURCES
"AriDecoder.cpp"
"ArwDecoder.cpp"
"BitPumpJPEG.cpp"
"BitPumpMSB.cpp"
"BitPumpMSB16.cpp"
"BitPumpMSB32.cpp"
"BitPumpPlain.cpp"
"BlackArea.cpp"
"ByteStream.cpp"
"ByteStreamSwap.cpp"
"Camera.cpp"
"CameraMetaData.cpp"
"CameraMetadataException.cpp"
"CameraSensorInfo.cpp"
"CiffEntry.cpp"
"CiffIFD.cpp"
"CiffParser.cpp"
"CiffParserException.cpp"
"ColorFilterArray.cpp"
"Common.cpp"
"Cr2Decoder.cpp"
"CrwDecoder.cpp"
"DcrDecoder.cpp"
"DcsDecoder.cpp"
"DngDecoder.cpp"
"DngDecoderSlices.cpp"
"DngOpcodes.cpp"
"ErfDecoder.cpp"
"FileIOException.cpp"
"FileMap.cpp"
"FileReader.cpp"
"FileWriter.cpp"
"HasselbladDecompressor.cpp"
"IOException.cpp"
"KdcDecoder.cpp"
"LJpegDecompressor.cpp"
"LJpegPlain.cpp"
"MefDecoder.cpp"
"MosDecoder.cpp"
"MrwDecoder.cpp"
"NakedDecoder.cpp"
"NefDecoder.cpp"
"NikonDecompressor.cpp"
"OrfDecoder.cpp"
"PefDecoder.cpp"
"PentaxDecompressor.cpp"
"RafDecoder.cpp"
"RawDecoder.cpp"
"RawDecoderException.cpp"
"RawImage.cpp"
"RawImageDataFloat.cpp"
"RawImageDataU16.cpp"
"RawParser.cpp"
"Rw2Decoder.cpp"
"SrwDecoder.cpp"
"StdAfx.cpp"
"ThreefrDecoder.cpp"
"TiffEntry.cpp"
"TiffEntryBE.cpp"
"TiffIFD.cpp"
"TiffIFDBE.cpp"
"TiffParser.cpp"
"TiffParserException.cpp"
"X3fDecoder.cpp"
"X3fParser.cpp"
)

#
# build librawspeed
#
if(WIN32)
set(RAWSPEED_LIBS "msvcrt")
endif(WIN32)

add_library(rawspeed STATIC ${RAWSPEED_SOURCES})

set_target_properties(rawspeed
PROPERTIES
POSITION_INDEPENDENT_CODE True
)

target_link_libraries(rawspeed ${RAWSPEED_LIBS} ${Pugixml_LIBRARIES} ${JPEG_LIBRARIES})

#
# the rawspeed part is a bit of a hack:
# the static linking didn't work since it was pulling -lstdc++ and -lm into linker flags.
# so we do a custom dependency and pretend an imported librawsped.a so no other -l are
# appended.
#
add_library(rawspeed_static STATIC IMPORTED GLOBAL)
set_target_properties(rawspeed_static
PROPERTIES
IMPORTED_LOCATION ${CMAKE_CURRENT_BINARY_DIR}/librawspeed.a
INTERFACE_LINK_LIBRARIES $<TARGET_PROPERTY:rawspeed,INTERFACE_LINK_LIBRARIES>
POSITION_INDEPENDENT_CODE True
)

add_dependencies(rawspeed_static rawspeed)
Loading

0 comments on commit 11f079c

Please sign in to comment.