Skip to content

Commit

Permalink
Merge branch 'release/v1.3.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
intelligide committed Jun 1, 2021
2 parents 2b7f79a + cb22171 commit d5cd924
Show file tree
Hide file tree
Showing 12 changed files with 78 additions and 44 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 ${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 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()

3 changes: 1 addition & 2 deletions 3rdparty/lzma/Linux/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ set(lzma_SOURCES
${CMAKE_CURRENT_SOURCE_DIR}/LzmaTypes.h
)


if(WIN32)
list(APPEND lzma_SOURCES
${CMAKE_CURRENT_SOURCE_DIR}/LzFindMt.cpp
Expand All @@ -41,7 +40,7 @@ if(WIN32)
)
endif()

add_library(lzma EXCLUDE_FROM_ALL STATIC ${lzma_SOURCES})
add_library(lzma OBJECT EXCLUDE_FROM_ALL ${lzma_SOURCES})
target_include_directories(lzma PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})

set_target_properties(lzma PROPERTIES
Expand Down
2 changes: 1 addition & 1 deletion 3rdparty/lzma/Windows/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ if(MSVC)
list(APPEND lzma_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/7zVersion.rc)
endif()

add_library(lzma EXCLUDE_FROM_ALL STATIC ${lzma_SOURCES} ${lzma_HEADERS})
add_library(lzma OBJECT EXCLUDE_FROM_ALL ${lzma_SOURCES} ${lzma_HEADERS})
target_include_directories(lzma PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})

set_target_properties(lzma PROPERTIES FOLDER "3rdparty")
4 changes: 2 additions & 2 deletions 3rdparty/miniz/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ if(miniz_FOUND)

else()

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

add_library(miniz STATIC EXCLUDE_FROM_ALL miniz.c miniz.h)
add_library(miniz OBJECT EXCLUDE_FROM_ALL miniz.c miniz.h)
target_include_directories(miniz PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})

set_target_properties(miniz PROPERTIES
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()
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.4)
cmake_minimum_required(VERSION 3.12)
project(Crunch2 VERSION "1.2.0")

if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/conanbuildinfo.cmake")
Expand Down
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
22 changes: 17 additions & 5 deletions crnlib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -162,12 +162,19 @@ add_library(crn ${CRNLIB_SRCS})
set_property(TARGET crn PROPERTY CXX_STANDARD 11)
target_include_directories(crn
PUBLIC
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/../inc
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../inc>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
# PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
)
target_link_libraries(crn
PRIVATE
$<BUILD_INTERFACE:lzma>
$<BUILD_INTERFACE:jpeg-compressor>
$<BUILD_INTERFACE:miniz>
$<BUILD_INTERFACE:stb>
)
target_link_libraries(crn PRIVATE lzma jpge jpgd miniz stb)

include(GenerateExportHeader)
generate_export_header(crn)
Expand All @@ -177,7 +184,12 @@ if(NOT WIN32)
target_link_libraries(crn PUBLIC Threads::Threads)
endif()

install(TARGETS crn)
install(TARGETS crn EXPORT crnTargets)
install(EXPORT crnTargets
FILE crunchTargets.cmake
NAMESPACE crunch::
DESTINATION lib/cmake/crunch
)
file(GLOB CRN_INC_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/../inc/*.h)
list(APPEND CRN_INC_HEADERS ${CMAKE_CURRENT_BINARY_DIR}/crn_export.h)
install(FILES ${CRN_INC_HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
4 changes: 2 additions & 2 deletions crnlib/crn_hash_map.h
Original file line number Diff line number Diff line change
Expand Up @@ -439,15 +439,15 @@ namespace crnlib
}
inline bool operator!=(const const_iterator& b) const
{
return *this != b;
return !(*this == b);
}
inline bool operator==(const iterator& b) const
{
return (m_pTable == b.m_pTable) && (m_index == b.m_index);
}
inline bool operator!=(const iterator& b) const
{
return *this != b;
return !(*this == b);
}

private:
Expand Down
6 changes: 3 additions & 3 deletions crnlib/crn_helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,19 @@ namespace crnlib
{
friend bool operator!=(const T& x, const T& y)
{
return x != y;
return (!(x == y));
}
friend bool operator>(const T& x, const T& y)
{
return (y < x);
}
friend bool operator<=(const T& x, const T& y)
{
return y >= x;
return (!(y < x));
}
friend bool operator>=(const T& x, const T& y)
{
return x >= y;
return (!(x < y));
}
};

Expand Down
10 changes: 5 additions & 5 deletions crunch/crunch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors 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 or credits
* is 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.
*/

Expand Down Expand Up @@ -1428,7 +1428,7 @@ static void print_title()
console::printf("crunch - Advanced DXTn Texture Compressor - https://github.com/FrozenStormInteractive/Crunch2");
console::printf("");
console::printf("Copyright (c) 2010-2016 Richard Geldreich, Jr. and Binomial LLC");
console::printf("Copyright (c) 2020 FrozenStorm Interactive, Yoann Potinet");
console::printf("Copyright (c) 2020-2021 FrozenStorm Interactive, Yoann Potinet");
console::printf("");
console::printf("crnlib version %s %s Built %s, %s", crn_get_version(), crnlib_is_x64() ? "x64" : "x86", __DATE__, __TIME__);
console::printf("");
Expand Down
1 change: 1 addition & 0 deletions test_package/test_package.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

int main()
{
crn_get_file_type_ext(crn_file_type::cCRNFileTypeCRN);
std::cout << "crnlib " << crn_get_version() << std::endl;
return 0;
}

0 comments on commit d5cd924

Please sign in to comment.