From 079b071dfc24d309fb22fa41ccd94a0a156cdb52 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Fri, 15 Nov 2019 17:54:09 +0100 Subject: [PATCH] Add CMake support (largely derived from https://github.com/BinomialLLC/crunch/pull/24) --- CMakeLists.txt | 28 ++++++++++++ crnlib/CMakeLists.txt | 101 ++++++++++++++++++++++++++++++++++++++++++ crunch/CMakeLists.txt | 19 ++++++++ 3 files changed, 148 insertions(+) create mode 100644 CMakeLists.txt create mode 100644 crnlib/CMakeLists.txt create mode 100644 crunch/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 00000000..db9fbdc1 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,28 @@ +# Ensure minimum CMake version. +cmake_minimum_required(VERSION 3.5 FATAL_ERROR) + +# Name the project. +project(crunch-project) + +# Add the source library files. +add_subdirectory(crnlib) + +# Add the command-line tool. +add_subdirectory(crunch) + +# Add the emscripten library. +# add_subdirectory(emscripten) + +# Add the examples. +# add_subdirectory(example1) +# add_subdirectory(example2) +# add_subdirectory(example3) + +install( + FILES + ${CMAKE_SOURCE_DIR}/inc/crn_decomp.h + ${CMAKE_SOURCE_DIR}/inc/crnlib.h + ${CMAKE_SOURCE_DIR}/inc/dds_defs.h + DESTINATION + include/crunch +) diff --git a/crnlib/CMakeLists.txt b/crnlib/CMakeLists.txt new file mode 100644 index 00000000..c6c2d58d --- /dev/null +++ b/crnlib/CMakeLists.txt @@ -0,0 +1,101 @@ +set(SRCFILES + crnlib.cpp + crn_arealist.cpp + crn_assert.cpp + crn_checksum.cpp + crn_colorized_console.cpp + crn_command_line_params.cpp + crn_comp.cpp + crn_console.cpp + crn_core.cpp + crn_data_stream.cpp + crn_dds_comp.cpp + crn_decomp.cpp + crn_dxt.cpp + crn_dxt1.cpp + crn_dxt5a.cpp + crn_dxt_endpoint_refiner.cpp + crn_dxt_fast.cpp + crn_dxt_hc.cpp + crn_dxt_hc_common.cpp + crn_dxt_image.cpp + crn_dynamic_string.cpp + crn_etc.cpp + crn_file_utils.cpp + crn_find_files.cpp + crn_hash.cpp + crn_hash_map.cpp + crn_huffman_codes.cpp + crn_image_utils.cpp + crn_jpgd.cpp + crn_jpge.cpp + crn_ktx_texture.cpp + crn_lzma_codec.cpp + crn_math.cpp + crn_mem.cpp + crn_miniz.cpp + crn_mipmapped_texture.cpp + crn_pixel_format.cpp + crn_platform.cpp + crn_prefix_coding.cpp + crn_qdxt1.cpp + crn_qdxt5.cpp + crn_rand.cpp + crn_resampler.cpp + crn_resample_filters.cpp + crn_rg_etc1.cpp + crn_ryg_dxt.cpp + crn_sparse_bit_array.cpp + crn_stb_image.cpp + crn_strutils.cpp + crn_symbol_codec.cpp + crn_texture_comp.cpp + crn_texture_conversion.cpp + crn_texture_file_types.cpp + crn_threaded_resampler.cpp + crn_timer.cpp + crn_utils.cpp + crn_value.cpp + crn_vector.cpp + crn_zeng.cpp + lzma_7zBuf.cpp + lzma_7zBuf2.cpp + lzma_7zCrc.cpp + lzma_7zFile.cpp + lzma_7zStream.cpp + lzma_Alloc.cpp + lzma_Bcj2.cpp + lzma_Bra.cpp + lzma_Bra86.cpp + lzma_BraIA64.cpp + lzma_LzFind.cpp + lzma_LzmaDec.cpp + lzma_LzmaEnc.cpp + lzma_LzmaLib.cpp +) + +IF (WIN32) + set(SRCFILES ${SRCFILES} + crn_threading_win32.cpp + lzma_LzFindMt.cpp + lzma_Threads.cpp + ) +ELSE () + set(SRCFILES ${SRCFILES} crn_threading_pthreads.cpp) +ENDIF (WIN32) + +IF (NOT WIN32) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC") +ENDIF (NOT WIN32) + +add_library(crunch STATIC ${SRCFILES}) + +IF (NOT WIN32) + target_link_libraries(crunch pthread) +ENDIF () + +target_include_directories(crunch + INTERFACE ${CMAKE_CURRENT_SOURCE_DIR} +) + +install(TARGETS crunch DESTINATION lib) diff --git a/crunch/CMakeLists.txt b/crunch/CMakeLists.txt new file mode 100644 index 00000000..b45b32e8 --- /dev/null +++ b/crunch/CMakeLists.txt @@ -0,0 +1,19 @@ +add_executable(crunch_exe + corpus_gen.cpp + corpus_test.cpp + crunch.cpp +) + +target_include_directories(crunch_exe + PUBLIC ${CMAKE_SOURCE_DIR}/inc +) + +target_link_libraries(crunch_exe + PUBLIC crunch +) + +set_target_properties(crunch_exe + PROPERTIES + OUTPUT_NAME crunch) + +install(TARGETS crunch_exe DESTINATION bin)