diff CMakeLists.txt @ 15:e05c257c6a23

*: huge refactor, add many new x86 intrinsics and the like ALSO!! now intrinsics are enabled at runtime, depending on what is detected. altivec *should* still work but I only tested compiling it. the major version has been updated to 2.0 for this...
author Paper <paper@tflc.us>
date Wed, 20 Nov 2024 04:10:37 -0500
parents 6e0eb3aa12ab
children 41dd962abdd1
line wrap: on
line diff
--- a/CMakeLists.txt	Tue Nov 19 15:55:01 2024 -0500
+++ b/CMakeLists.txt	Wed Nov 20 04:10:37 2024 -0500
@@ -1,10 +1,42 @@
 cmake_minimum_required(VERSION 3.5)
 
-project(vec VERSION 1.0.0 DESCRIPTION "a tiny C99 SIMD vector library")
+project(vec VERSION 2.0.0 DESCRIPTION "a tiny C99 SIMD vector library")
 
 add_library(vec SHARED src/vec.c)
 
-set_target_properties(vec PROPERTIES PUBLIC_HEADER include/vec/vec.h)
+include(CheckCCompilerFlag)
+
+if(MSVC)
+	# TODO ?
+else()
+	check_c_compiler_flag("-maltivec" COMPILER_HAS_ALTIVEC)
+	if(COMPILER_HAS_ALTIVEC)
+		target_compile_options(vec PRIVATE "-maltivec")
+	endif()
+	check_c_compiler_flag("-mmmx" COMPILER_HAS_MMX)
+	if(COMPILER_HAS_MMX)
+		target_compile_options(vec PRIVATE "-mmmx")
+	endif()
+	check_c_compiler_flag("-msse2" COMPILER_HAS_SSE2)
+	if(COMPILER_HAS_SSE2)
+		target_compile_options(vec PRIVATE "-msse2")
+	endif()
+	check_c_compiler_flag("-msse4.1" COMPILER_HAS_SSE41)
+	if(COMPILER_HAS_SSE41)
+		target_compile_options(vec PRIVATE "-msse4.1")
+	endif()
+	check_c_compiler_flag("-mavx2" COMPILER_HAS_AVX2)
+	if(COMPILER_HAS_AVX2)
+		target_compile_options(vec PRIVATE "-mavx2")
+	endif()
+	check_c_compiler_flag("-mavx512f" COMPILER_HAS_AVX512F)
+	if(COMPILER_HAS_AVX512F)
+		target_compile_options(vec PRIVATE "-mavx512f")
+	endif()
+endif()
+
+
+set_target_properties(vec PROPERTIES PUBLIC_HEADER include/vec/vec.h C_STANDARD 99)
 
 target_include_directories(vec PRIVATE include)
 
@@ -13,9 +45,9 @@
 include(GNUInstallDirs)
 
 install(TARGETS vec
-    LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
-    PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
+	LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+	PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
 
 # pkg-config
 configure_file(vec.pc.in vec.pc @ONLY)
-install(FILES ${CMAKE_BINARY_DIR}/vec.pc DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/pkgconfig)
\ No newline at end of file
+install(FILES ${CMAKE_BINARY_DIR}/vec.pc DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/pkgconfig)