Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ project(Correct C)
include(CheckLibraryExists)
include(CheckIncludeFiles)
include(CheckCSourceCompiles)
include(CMakePushCheckState)

if(MSVC)
set(LIBM "")
Expand All @@ -27,15 +28,24 @@ endif(MSVC)

find_library(FEC fec)
CHECK_LIBRARY_EXISTS(FEC dotprod "" HAVE_LIBFEC)
check_c_source_compiles("

if(NOT CMAKE_CROSSCOMPILING)
# Check if host machine can compile with SSE 4.1 intrinsic
cmake_push_check_state(RESET)
set(CMAKE_REQUIRED_DEFINITIONS -march=native)
check_c_source_compiles("
#include <x86intrin.h>
int main() {
__m128i vec;
__m128i a;
__m128i b;
__m128i c = _mm_min_epu16(a, b);
return 0;
}" HAVE_SSE)
cmake_pop_check_state()
endif()

if(HAVE_SSE)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse4.2")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse4.1")
endif()

set(CMAKE_CXX_VISIBILITY_PRESET hidden)
Expand All @@ -54,13 +64,16 @@ if(HAVE_SSE)
set(correct_obj_files $<TARGET_OBJECTS:correct-reed-solomon> $<TARGET_OBJECTS:correct-convolutional> $<TARGET_OBJECTS:correct-convolutional-sse>)
set(INSTALL_HEADERS ${INSTALL_HEADERS} ${PROJECT_BINARY_DIR}/include/correct-sse.h)
add_custom_target(correct-sse-h ALL COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_SOURCE_DIR}/include/correct-sse.h ${PROJECT_BINARY_DIR}/include/correct-sse.h)
add_definitions(-DHAVE_SSE=1)
else()
set(correct_obj_files $<TARGET_OBJECTS:correct-reed-solomon> $<TARGET_OBJECTS:correct-convolutional>)
endif()
add_library(correct SHARED ${correct_obj_files})
add_library(correct_static ${correct_obj_files})
set_target_properties(correct_static PROPERTIES OUTPUT_NAME "correct")
if(HAVE_SSE)
target_compile_definitions(correct PUBLIC HAVE_SSE=1)
target_compile_definitions(correct_static PUBLIC HAVE_SSE=1)
endif()

add_subdirectory(util)
add_subdirectory(tests)
Expand Down