Skip to content

Commit

Permalink
Add jpeg-compressor from conan
Browse files Browse the repository at this point in the history
  • Loading branch information
intelligide committed Feb 24, 2021
1 parent 8e2d8d9 commit 3514052
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 26 deletions.
61 changes: 41 additions & 20 deletions 3rdparty/jpeg-compressor/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,23 +1,44 @@
cmake_minimum_required(VERSION 3.0)
project(jpeg-compressor)

set(BUILD_SHARED_LIBS OFF)

set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

set(JPGD_SRC_LIST jpgd.cpp)
set(JPGD_HDR_LIST jpgd.h jpgd_idct.h)
add_library(jpgd OBJECT EXCLUDE_FROM_ALL ${JPGD_SRC_LIST} ${JPGD_HDR_LIST})
target_include_directories(jpgd PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})

set(JPGE_SRC_LIST jpge.cpp)
set(JPGE_HDR_LIST jpge.h jpge.h)
add_library(jpge OBJECT EXCLUDE_FROM_ALL ${JPGE_SRC_LIST} ${JPGE_HDR_LIST})
target_include_directories(jpge PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})

set_target_properties(jpgd jpge PROPERTIES
FOLDER "3rdparty"
POSITION_INDEPENDENT_CODE ON
)
find_package(jpeg-compressor QUIET)

if(jpeg-compressor_FOUND)

if(NOT TARGET jpeg-compressor)
if(TARGET jpeg-compressor::jpeg-compressor)
add_library(jpeg-compressor ALIAS jpeg-compressor::jpeg-compressor)
else()
add_library(jpeg-compressor INTERFACE)
if(jpeg-compressor_INCLUDE_DIRS)
target_include_directories(jpeg-compressor INTERFACE ${jpeg-compressor_INCLUDE_DIRS})
endif()
if(jpeg-compressor_LIBRARIES)
target_link_libraries(jpeg-compressor INTERFACE ${jpeg-compressor_LIBRARIES})
endif()
if(jpeg-compressor_COMPILE_DEFINITIONS)
target_compile_definitions(jpeg-compressor INTERFACE ${jpeg-compressor_COMPILE_DEFINITIONS})
endif()
if(jpeg-compressor_COMPILE_OPTIONS_LIST)
target_compile_options(jpeg-compressor INTERFACE ${jpeg-compressor_COMPILE_OPTIONS_LIST})
endif()
endif()
endif()

else()

message(STATUS "jpeg-compressor not found")
message(STATUS "Building jpeg-compressor from 3rdparty sources")

set(JPGC_SRC_LIST jpgd.cpp jpge.cpp)
set(JPGC_HDR_LIST jpgd.h jpgd_idct.h jpge.h)
add_library(jpeg-compressor OBJECT EXCLUDE_FROM_ALL ${JPGC_SRC_LIST} ${JPGC_HDR_LIST})
target_include_directories(jpeg-compressor PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})

set_target_properties(jpeg-compressor PROPERTIES
FOLDER "3rdparty"
POSITION_INDEPENDENT_CODE ON
)

endif()

2 changes: 1 addition & 1 deletion 3rdparty/miniz/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ if(miniz_FOUND)

else()

message(STATUS "Miniz not found")
message(STATUS "miniz not found")
message(STATUS "Building miniz from 3rdparty sources")

add_library(miniz OBJECT EXCLUDE_FROM_ALL miniz.c miniz.h)
Expand Down
4 changes: 2 additions & 2 deletions 3rdparty/stb/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ if(stb_FOUND)

else()

message(STATUS "Stb not found")
message(STATUS "stb not found")
message(STATUS "Building stb from 3rdparty sources")

add_library(stb INTERFACE)
target_include_directories(stb INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})
target_include_directories(stb INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})

endif()
3 changes: 2 additions & 1 deletion conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class Crunch2Conan(ConanFile):
"fPIC": True,
"shared": False,
}

_cmake = None

@property
Expand All @@ -37,6 +37,7 @@ def configure(self):
def requirements(self):
self.requires("miniz/2.1.0")
self.requires("stb/20200203")
self.requires("jpeg-compressor/cci.20200507")

def _configure_cmake(self):
if self._cmake:
Expand Down
3 changes: 1 addition & 2 deletions crnlib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,7 @@ target_include_directories(crn
target_link_libraries(crn
PRIVATE
$<BUILD_INTERFACE:lzma>
$<BUILD_INTERFACE:jpge>
$<BUILD_INTERFACE:jpgd>
$<BUILD_INTERFACE:jpeg-compressor>
$<BUILD_INTERFACE:miniz>
$<BUILD_INTERFACE:stb>
)
Expand Down

0 comments on commit 3514052

Please sign in to comment.