Skip to content

Commit

Permalink
Add CMake support (largely derived from BinomialLLC#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
rouault committed Nov 15, 2019
1 parent 314d806 commit 079b071
Show file tree
Hide file tree
Showing 3 changed files with 148 additions and 0 deletions.
28 changes: 28 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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
)
101 changes: 101 additions & 0 deletions crnlib/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
19 changes: 19 additions & 0 deletions crunch/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 079b071

Please sign in to comment.