Skip to content

Commit d5cd924

Browse files
committed
Merge branch 'release/v1.3.1'
2 parents 2b7f79a + cb22171 commit d5cd924

File tree

12 files changed

+78
-44
lines changed

12 files changed

+78
-44
lines changed
Lines changed: 41 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,44 @@
11
cmake_minimum_required(VERSION 3.0)
22
project(jpeg-compressor)
33

4-
set(BUILD_SHARED_LIBS OFF)
5-
6-
set(CMAKE_CXX_STANDARD 11)
7-
set(CMAKE_CXX_STANDARD_REQUIRED ON)
8-
set(CMAKE_CXX_EXTENSIONS OFF)
9-
10-
set(JPGD_SRC_LIST jpgd.cpp)
11-
set(JPGD_HDR_LIST jpgd.h jpgd_idct.h)
12-
add_library(jpgd ${JPGD_SRC_LIST} ${JPGD_HDR_LIST})
13-
target_include_directories(jpgd PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
14-
15-
set(JPGE_SRC_LIST jpge.cpp)
16-
set(JPGE_HDR_LIST jpge.h jpge.h)
17-
add_library(jpge EXCLUDE_FROM_ALL ${JPGE_SRC_LIST} ${JPGE_HDR_LIST})
18-
target_include_directories(jpge PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
19-
20-
set_target_properties(jpgd jpge PROPERTIES
21-
FOLDER "3rdparty"
22-
POSITION_INDEPENDENT_CODE ON
23-
)
4+
find_package(jpeg-compressor QUIET)
5+
6+
if(jpeg-compressor_FOUND)
7+
8+
if(NOT TARGET jpeg-compressor)
9+
if(TARGET jpeg-compressor::jpeg-compressor)
10+
add_library(jpeg-compressor ALIAS jpeg-compressor::jpeg-compressor)
11+
else()
12+
add_library(jpeg-compressor INTERFACE)
13+
if(jpeg-compressor_INCLUDE_DIRS)
14+
target_include_directories(jpeg-compressor INTERFACE ${jpeg-compressor_INCLUDE_DIRS})
15+
endif()
16+
if(jpeg-compressor_LIBRARIES)
17+
target_link_libraries(jpeg-compressor INTERFACE ${jpeg-compressor_LIBRARIES})
18+
endif()
19+
if(jpeg-compressor_COMPILE_DEFINITIONS)
20+
target_compile_definitions(jpeg-compressor INTERFACE ${jpeg-compressor_COMPILE_DEFINITIONS})
21+
endif()
22+
if(jpeg-compressor_COMPILE_OPTIONS_LIST)
23+
target_compile_options(jpeg-compressor INTERFACE ${jpeg-compressor_COMPILE_OPTIONS_LIST})
24+
endif()
25+
endif()
26+
endif()
27+
28+
else()
29+
30+
message(STATUS "jpeg-compressor not found")
31+
message(STATUS "Building jpeg-compressor from 3rdparty sources")
32+
33+
set(JPGC_SRC_LIST jpgd.cpp jpge.cpp)
34+
set(JPGC_HDR_LIST jpgd.h jpgd_idct.h jpge.h)
35+
add_library(jpeg-compressor OBJECT EXCLUDE_FROM_ALL ${JPGC_SRC_LIST} ${JPGC_HDR_LIST})
36+
target_include_directories(jpeg-compressor PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
37+
38+
set_target_properties(jpeg-compressor PROPERTIES
39+
FOLDER "3rdparty"
40+
POSITION_INDEPENDENT_CODE ON
41+
)
42+
43+
endif()
44+

3rdparty/lzma/Linux/CMakeLists.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ set(lzma_SOURCES
3131
${CMAKE_CURRENT_SOURCE_DIR}/LzmaTypes.h
3232
)
3333

34-
3534
if(WIN32)
3635
list(APPEND lzma_SOURCES
3736
${CMAKE_CURRENT_SOURCE_DIR}/LzFindMt.cpp
@@ -41,7 +40,7 @@ if(WIN32)
4140
)
4241
endif()
4342

44-
add_library(lzma EXCLUDE_FROM_ALL STATIC ${lzma_SOURCES})
43+
add_library(lzma OBJECT EXCLUDE_FROM_ALL ${lzma_SOURCES})
4544
target_include_directories(lzma PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
4645

4746
set_target_properties(lzma PROPERTIES

3rdparty/lzma/Windows/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ if(MSVC)
77
list(APPEND lzma_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/7zVersion.rc)
88
endif()
99

10-
add_library(lzma EXCLUDE_FROM_ALL STATIC ${lzma_SOURCES} ${lzma_HEADERS})
10+
add_library(lzma OBJECT EXCLUDE_FROM_ALL ${lzma_SOURCES} ${lzma_HEADERS})
1111
target_include_directories(lzma PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
1212

1313
set_target_properties(lzma PROPERTIES FOLDER "3rdparty")

3rdparty/miniz/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ if(miniz_FOUND)
2727

2828
else()
2929

30-
message(STATUS "Miniz not found")
30+
message(STATUS "miniz not found")
3131
message(STATUS "Building miniz from 3rdparty sources")
3232

33-
add_library(miniz STATIC EXCLUDE_FROM_ALL miniz.c miniz.h)
33+
add_library(miniz OBJECT EXCLUDE_FROM_ALL miniz.c miniz.h)
3434
target_include_directories(miniz PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
3535

3636
set_target_properties(miniz PROPERTIES

3rdparty/stb/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ if(stb_FOUND)
2323

2424
else()
2525

26-
message(STATUS "Stb not found")
26+
message(STATUS "stb not found")
2727
message(STATUS "Building stb from 3rdparty sources")
2828

2929
add_library(stb INTERFACE)
30-
target_include_directories(stb INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})
30+
target_include_directories(stb INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})
3131

3232
endif()

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cmake_minimum_required(VERSION 3.4)
1+
cmake_minimum_required(VERSION 3.12)
22
project(Crunch2 VERSION "1.2.0")
33

44
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/conanbuildinfo.cmake")

conanfile.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class Crunch2Conan(ConanFile):
1919
"fPIC": True,
2020
"shared": False,
2121
}
22-
22+
2323
_cmake = None
2424

2525
@property
@@ -37,6 +37,7 @@ def configure(self):
3737
def requirements(self):
3838
self.requires("miniz/2.1.0")
3939
self.requires("stb/20200203")
40+
self.requires("jpeg-compressor/cci.20200507")
4041

4142
def _configure_cmake(self):
4243
if self._cmake:

crnlib/CMakeLists.txt

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -162,12 +162,19 @@ add_library(crn ${CRNLIB_SRCS})
162162
set_property(TARGET crn PROPERTY CXX_STANDARD 11)
163163
target_include_directories(crn
164164
PUBLIC
165-
${CMAKE_CURRENT_BINARY_DIR}
166-
${CMAKE_CURRENT_SOURCE_DIR}/../inc
165+
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
166+
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../inc>
167+
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
167168
# PRIVATE
168-
${CMAKE_CURRENT_SOURCE_DIR}
169+
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
170+
)
171+
target_link_libraries(crn
172+
PRIVATE
173+
$<BUILD_INTERFACE:lzma>
174+
$<BUILD_INTERFACE:jpeg-compressor>
175+
$<BUILD_INTERFACE:miniz>
176+
$<BUILD_INTERFACE:stb>
169177
)
170-
target_link_libraries(crn PRIVATE lzma jpge jpgd miniz stb)
171178

172179
include(GenerateExportHeader)
173180
generate_export_header(crn)
@@ -177,7 +184,12 @@ if(NOT WIN32)
177184
target_link_libraries(crn PUBLIC Threads::Threads)
178185
endif()
179186

180-
install(TARGETS crn)
187+
install(TARGETS crn EXPORT crnTargets)
188+
install(EXPORT crnTargets
189+
FILE crunchTargets.cmake
190+
NAMESPACE crunch::
191+
DESTINATION lib/cmake/crunch
192+
)
181193
file(GLOB CRN_INC_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/../inc/*.h)
182194
list(APPEND CRN_INC_HEADERS ${CMAKE_CURRENT_BINARY_DIR}/crn_export.h)
183195
install(FILES ${CRN_INC_HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})

crnlib/crn_hash_map.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -439,15 +439,15 @@ namespace crnlib
439439
}
440440
inline bool operator!=(const const_iterator& b) const
441441
{
442-
return *this != b;
442+
return !(*this == b);
443443
}
444444
inline bool operator==(const iterator& b) const
445445
{
446446
return (m_pTable == b.m_pTable) && (m_index == b.m_index);
447447
}
448448
inline bool operator!=(const iterator& b) const
449449
{
450-
return *this != b;
450+
return !(*this == b);
451451
}
452452

453453
private:

crnlib/crn_helpers.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,19 +40,19 @@ namespace crnlib
4040
{
4141
friend bool operator!=(const T& x, const T& y)
4242
{
43-
return x != y;
43+
return (!(x == y));
4444
}
4545
friend bool operator>(const T& x, const T& y)
4646
{
4747
return (y < x);
4848
}
4949
friend bool operator<=(const T& x, const T& y)
5050
{
51-
return y >= x;
51+
return (!(y < x));
5252
}
5353
friend bool operator>=(const T& x, const T& y)
5454
{
55-
return x >= y;
55+
return (!(x < y));
5656
}
5757
};
5858

0 commit comments

Comments
 (0)