annotate CMakeLists.txt @ 27:d00b95f95dd1 default tip

impl/arm/neon: it compiles again, but is untested
author Paper <paper@tflc.us>
date Mon, 25 Nov 2024 00:33:02 -0500
parents 92156fe32755
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
17
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents: 15
diff changeset
1 cmake_minimum_required(VERSION 3.23)
8
6e0eb3aa12ab build: add files to build vec as an external library
Paper <paper@tflc.us>
parents:
diff changeset
2
25
92156fe32755 impl/ppc/altivec: update to new implementation
Paper <paper@tflc.us>
parents: 23
diff changeset
3 project(vec VERSION 3.0.0 DESCRIPTION "a tiny C99 SIMD vector library" LANGUAGES C)
8
6e0eb3aa12ab build: add files to build vec as an external library
Paper <paper@tflc.us>
parents:
diff changeset
4
23
e26874655738 *: huge refactor, new major release (hahaha)
Paper <paper@tflc.us>
parents: 17
diff changeset
5 add_library(vec SHARED "src/vec.c;src/cpu.c;src/impl/generic.c;src/impl/fallback.c")
17
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents: 15
diff changeset
6
15
e05c257c6a23 *: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents: 8
diff changeset
7 include(CheckCCompilerFlag)
e05c257c6a23 *: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents: 8
diff changeset
8
e05c257c6a23 *: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents: 8
diff changeset
9 if(MSVC)
23
e26874655738 *: huge refactor, new major release (hahaha)
Paper <paper@tflc.us>
parents: 17
diff changeset
10 # Untested!
e26874655738 *: huge refactor, new major release (hahaha)
Paper <paper@tflc.us>
parents: 17
diff changeset
11
e26874655738 *: huge refactor, new major release (hahaha)
Paper <paper@tflc.us>
parents: 17
diff changeset
12 if(CMAKE_SIZEOF_VOID_P EQUAL 8)
e26874655738 *: huge refactor, new major release (hahaha)
Paper <paper@tflc.us>
parents: 17
diff changeset
13 set(COMPILER_HAS_MMX OFF)
e26874655738 *: huge refactor, new major release (hahaha)
Paper <paper@tflc.us>
parents: 17
diff changeset
14 else()
e26874655738 *: huge refactor, new major release (hahaha)
Paper <paper@tflc.us>
parents: 17
diff changeset
15 set(COMPILER_HAS_MMX ON)
e26874655738 *: huge refactor, new major release (hahaha)
Paper <paper@tflc.us>
parents: 17
diff changeset
16 set(COMPILER_MMX_FLAGS "") # none?
e26874655738 *: huge refactor, new major release (hahaha)
Paper <paper@tflc.us>
parents: 17
diff changeset
17 endif()
e26874655738 *: huge refactor, new major release (hahaha)
Paper <paper@tflc.us>
parents: 17
diff changeset
18 check_c_compiler_flag("/arch:SSE2" COMPILER_HAS_SSE2)
e26874655738 *: huge refactor, new major release (hahaha)
Paper <paper@tflc.us>
parents: 17
diff changeset
19 if(COMPILER_HAS_SSE2)
e26874655738 *: huge refactor, new major release (hahaha)
Paper <paper@tflc.us>
parents: 17
diff changeset
20 set(COMPILER_SSE2_FLAGS "/arch:SSE2")
e26874655738 *: huge refactor, new major release (hahaha)
Paper <paper@tflc.us>
parents: 17
diff changeset
21 endif()
e26874655738 *: huge refactor, new major release (hahaha)
Paper <paper@tflc.us>
parents: 17
diff changeset
22 check_c_compiler_flag("/arch:SSE4.2" COMPILER_HAS_SSE41)
e26874655738 *: huge refactor, new major release (hahaha)
Paper <paper@tflc.us>
parents: 17
diff changeset
23 if(COMPILER_HAS_SSE41)
e26874655738 *: huge refactor, new major release (hahaha)
Paper <paper@tflc.us>
parents: 17
diff changeset
24 set(COMPILER_SSE41_FLAGS "/arch:SSE4.2")
e26874655738 *: huge refactor, new major release (hahaha)
Paper <paper@tflc.us>
parents: 17
diff changeset
25 endif()
e26874655738 *: huge refactor, new major release (hahaha)
Paper <paper@tflc.us>
parents: 17
diff changeset
26 check_c_compiler_flag("/arch:AVX2" COMPILER_HAS_AVX2)
e26874655738 *: huge refactor, new major release (hahaha)
Paper <paper@tflc.us>
parents: 17
diff changeset
27 if(COMPILER_HAS_AVX2)
e26874655738 *: huge refactor, new major release (hahaha)
Paper <paper@tflc.us>
parents: 17
diff changeset
28 set(COMPILER_AVX2_FLAGS "/arch:AVX2")
e26874655738 *: huge refactor, new major release (hahaha)
Paper <paper@tflc.us>
parents: 17
diff changeset
29 endif()
e26874655738 *: huge refactor, new major release (hahaha)
Paper <paper@tflc.us>
parents: 17
diff changeset
30 check_c_compiler_flag("/arch:AVX512" COMPILER_HAS_AVX512F)
e26874655738 *: huge refactor, new major release (hahaha)
Paper <paper@tflc.us>
parents: 17
diff changeset
31 if(COMPILER_HAS_AVX512F)
e26874655738 *: huge refactor, new major release (hahaha)
Paper <paper@tflc.us>
parents: 17
diff changeset
32 set(COMPILER_AVX512F_FLAGS "/arch:AVX512")
e26874655738 *: huge refactor, new major release (hahaha)
Paper <paper@tflc.us>
parents: 17
diff changeset
33 endif()
e26874655738 *: huge refactor, new major release (hahaha)
Paper <paper@tflc.us>
parents: 17
diff changeset
34 # TODO we have to try_compile to detect NEON
15
e05c257c6a23 *: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents: 8
diff changeset
35 else()
25
92156fe32755 impl/ppc/altivec: update to new implementation
Paper <paper@tflc.us>
parents: 23
diff changeset
36 check_c_compiler_flag("-maltivec" COMPILER_HAS_ALTIVEC)
92156fe32755 impl/ppc/altivec: update to new implementation
Paper <paper@tflc.us>
parents: 23
diff changeset
37 if(COMPILER_HAS_ALTIVEC)
92156fe32755 impl/ppc/altivec: update to new implementation
Paper <paper@tflc.us>
parents: 23
diff changeset
38 set(COMPILER_ALTIVEC_FLAGS "-maltivec")
92156fe32755 impl/ppc/altivec: update to new implementation
Paper <paper@tflc.us>
parents: 23
diff changeset
39 endif()
27
d00b95f95dd1 impl/arm/neon: it compiles again, but is untested
Paper <paper@tflc.us>
parents: 25
diff changeset
40 check_c_compiler_flag("-mfpu=neon" COMPILER_HAS_NEON)
d00b95f95dd1 impl/arm/neon: it compiles again, but is untested
Paper <paper@tflc.us>
parents: 25
diff changeset
41 if(COMPILER_HAS_NEON)
d00b95f95dd1 impl/arm/neon: it compiles again, but is untested
Paper <paper@tflc.us>
parents: 25
diff changeset
42 set(COMPILER_NEON_FLAGS "-mfpu=neon")
d00b95f95dd1 impl/arm/neon: it compiles again, but is untested
Paper <paper@tflc.us>
parents: 25
diff changeset
43 endif()
15
e05c257c6a23 *: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents: 8
diff changeset
44 check_c_compiler_flag("-mmmx" COMPILER_HAS_MMX)
e05c257c6a23 *: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents: 8
diff changeset
45 if(COMPILER_HAS_MMX)
23
e26874655738 *: huge refactor, new major release (hahaha)
Paper <paper@tflc.us>
parents: 17
diff changeset
46 set(COMPILER_MMX_FLAGS "-mmmx")
15
e05c257c6a23 *: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents: 8
diff changeset
47 endif()
e05c257c6a23 *: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents: 8
diff changeset
48 check_c_compiler_flag("-msse2" COMPILER_HAS_SSE2)
e05c257c6a23 *: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents: 8
diff changeset
49 if(COMPILER_HAS_SSE2)
23
e26874655738 *: huge refactor, new major release (hahaha)
Paper <paper@tflc.us>
parents: 17
diff changeset
50 set(COMPILER_SSE2_FLAGS "-msse2")
15
e05c257c6a23 *: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents: 8
diff changeset
51 endif()
e05c257c6a23 *: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents: 8
diff changeset
52 check_c_compiler_flag("-msse4.1" COMPILER_HAS_SSE41)
e05c257c6a23 *: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents: 8
diff changeset
53 if(COMPILER_HAS_SSE41)
23
e26874655738 *: huge refactor, new major release (hahaha)
Paper <paper@tflc.us>
parents: 17
diff changeset
54 set(COMPILER_SSE41_FLAGS "-msse4.1")
15
e05c257c6a23 *: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents: 8
diff changeset
55 endif()
e05c257c6a23 *: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents: 8
diff changeset
56 check_c_compiler_flag("-mavx2" COMPILER_HAS_AVX2)
e05c257c6a23 *: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents: 8
diff changeset
57 if(COMPILER_HAS_AVX2)
23
e26874655738 *: huge refactor, new major release (hahaha)
Paper <paper@tflc.us>
parents: 17
diff changeset
58 set(COMPILER_AVX2_FLAGS "-mavx2")
15
e05c257c6a23 *: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents: 8
diff changeset
59 endif()
e05c257c6a23 *: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents: 8
diff changeset
60 check_c_compiler_flag("-mavx512f" COMPILER_HAS_AVX512F)
e05c257c6a23 *: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents: 8
diff changeset
61 if(COMPILER_HAS_AVX512F)
23
e26874655738 *: huge refactor, new major release (hahaha)
Paper <paper@tflc.us>
parents: 17
diff changeset
62 set(COMPILER_AVX512F_FLAGS "-mavx512f")
15
e05c257c6a23 *: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents: 8
diff changeset
63 endif()
e05c257c6a23 *: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents: 8
diff changeset
64 endif()
e05c257c6a23 *: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents: 8
diff changeset
65
23
e26874655738 *: huge refactor, new major release (hahaha)
Paper <paper@tflc.us>
parents: 17
diff changeset
66 if(COMPILER_HAS_ALTIVEC)
e26874655738 *: huge refactor, new major release (hahaha)
Paper <paper@tflc.us>
parents: 17
diff changeset
67 target_sources(vec PRIVATE "src/impl/ppc/altivec.c")
e26874655738 *: huge refactor, new major release (hahaha)
Paper <paper@tflc.us>
parents: 17
diff changeset
68 set_source_files_properties("src/impl/ppc/altivec.c" PROPERTIES COMPILE_FLAGS "${COMPILER_ALTIVEC_FLAGS}")
e26874655738 *: huge refactor, new major release (hahaha)
Paper <paper@tflc.us>
parents: 17
diff changeset
69 target_compile_definitions(vec PRIVATE "-DVEC_COMPILER_HAS_ALTIVEC")
e26874655738 *: huge refactor, new major release (hahaha)
Paper <paper@tflc.us>
parents: 17
diff changeset
70 endif()
e26874655738 *: huge refactor, new major release (hahaha)
Paper <paper@tflc.us>
parents: 17
diff changeset
71
e26874655738 *: huge refactor, new major release (hahaha)
Paper <paper@tflc.us>
parents: 17
diff changeset
72 if(COMPILER_HAS_NEON)
e26874655738 *: huge refactor, new major release (hahaha)
Paper <paper@tflc.us>
parents: 17
diff changeset
73 target_sources(vec PRIVATE "src/impl/arm/neon.c")
e26874655738 *: huge refactor, new major release (hahaha)
Paper <paper@tflc.us>
parents: 17
diff changeset
74 set_source_files_properties("src/impl/arm/neon.c" PROPERTIES COMPILE_FLAGS "${COMPILER_NEON_FLAGS}")
e26874655738 *: huge refactor, new major release (hahaha)
Paper <paper@tflc.us>
parents: 17
diff changeset
75 target_compile_definitions(vec PRIVATE "-DVEC_COMPILER_HAS_NEON")
e26874655738 *: huge refactor, new major release (hahaha)
Paper <paper@tflc.us>
parents: 17
diff changeset
76 endif()
e26874655738 *: huge refactor, new major release (hahaha)
Paper <paper@tflc.us>
parents: 17
diff changeset
77
e26874655738 *: huge refactor, new major release (hahaha)
Paper <paper@tflc.us>
parents: 17
diff changeset
78 if(COMPILER_HAS_MMX)
e26874655738 *: huge refactor, new major release (hahaha)
Paper <paper@tflc.us>
parents: 17
diff changeset
79 target_sources(vec PRIVATE "src/impl/x86/mmx.c")
e26874655738 *: huge refactor, new major release (hahaha)
Paper <paper@tflc.us>
parents: 17
diff changeset
80 set_source_files_properties("src/impl/x86/mmx.c" PROPERTIES COMPILE_FLAGS "${COMPILER_MMX_FLAGS}")
e26874655738 *: huge refactor, new major release (hahaha)
Paper <paper@tflc.us>
parents: 17
diff changeset
81 target_compile_definitions(vec PRIVATE "-DVEC_COMPILER_HAS_MMX")
e26874655738 *: huge refactor, new major release (hahaha)
Paper <paper@tflc.us>
parents: 17
diff changeset
82 endif()
e26874655738 *: huge refactor, new major release (hahaha)
Paper <paper@tflc.us>
parents: 17
diff changeset
83
e26874655738 *: huge refactor, new major release (hahaha)
Paper <paper@tflc.us>
parents: 17
diff changeset
84 if(COMPILER_HAS_SSE2)
e26874655738 *: huge refactor, new major release (hahaha)
Paper <paper@tflc.us>
parents: 17
diff changeset
85 target_sources(vec PRIVATE "src/impl/x86/sse2.c")
e26874655738 *: huge refactor, new major release (hahaha)
Paper <paper@tflc.us>
parents: 17
diff changeset
86 set_source_files_properties("src/impl/x86/sse2.c" PROPERTIES COMPILE_FLAGS "${COMPILER_SSE2_FLAGS}")
e26874655738 *: huge refactor, new major release (hahaha)
Paper <paper@tflc.us>
parents: 17
diff changeset
87 target_compile_definitions(vec PRIVATE "-DVEC_COMPILER_HAS_SSE2")
e26874655738 *: huge refactor, new major release (hahaha)
Paper <paper@tflc.us>
parents: 17
diff changeset
88 endif()
e26874655738 *: huge refactor, new major release (hahaha)
Paper <paper@tflc.us>
parents: 17
diff changeset
89
e26874655738 *: huge refactor, new major release (hahaha)
Paper <paper@tflc.us>
parents: 17
diff changeset
90 if(COMPILER_HAS_SSE41)
e26874655738 *: huge refactor, new major release (hahaha)
Paper <paper@tflc.us>
parents: 17
diff changeset
91 target_sources(vec PRIVATE "src/impl/x86/sse41.c")
e26874655738 *: huge refactor, new major release (hahaha)
Paper <paper@tflc.us>
parents: 17
diff changeset
92 set_source_files_properties("src/impl/x86/sse41.c" PROPERTIES COMPILE_FLAGS "${COMPILER_SSE41_FLAGS}")
e26874655738 *: huge refactor, new major release (hahaha)
Paper <paper@tflc.us>
parents: 17
diff changeset
93 target_compile_definitions(vec PRIVATE "-DVEC_COMPILER_HAS_SSE41")
e26874655738 *: huge refactor, new major release (hahaha)
Paper <paper@tflc.us>
parents: 17
diff changeset
94 endif()
e26874655738 *: huge refactor, new major release (hahaha)
Paper <paper@tflc.us>
parents: 17
diff changeset
95
e26874655738 *: huge refactor, new major release (hahaha)
Paper <paper@tflc.us>
parents: 17
diff changeset
96 if(COMPILER_HAS_AVX2)
e26874655738 *: huge refactor, new major release (hahaha)
Paper <paper@tflc.us>
parents: 17
diff changeset
97 target_sources(vec PRIVATE "src/impl/x86/avx2.c")
e26874655738 *: huge refactor, new major release (hahaha)
Paper <paper@tflc.us>
parents: 17
diff changeset
98 set_source_files_properties("src/impl/x86/avx2.c" PROPERTIES COMPILE_FLAGS "${COMPILER_AVX2_FLAGS}")
e26874655738 *: huge refactor, new major release (hahaha)
Paper <paper@tflc.us>
parents: 17
diff changeset
99 target_compile_definitions(vec PRIVATE "-DVEC_COMPILER_HAS_AVX2")
e26874655738 *: huge refactor, new major release (hahaha)
Paper <paper@tflc.us>
parents: 17
diff changeset
100 endif()
e26874655738 *: huge refactor, new major release (hahaha)
Paper <paper@tflc.us>
parents: 17
diff changeset
101
e26874655738 *: huge refactor, new major release (hahaha)
Paper <paper@tflc.us>
parents: 17
diff changeset
102 if(COMPILER_HAS_AVX512F)
e26874655738 *: huge refactor, new major release (hahaha)
Paper <paper@tflc.us>
parents: 17
diff changeset
103 target_sources(vec PRIVATE "src/impl/x86/avx512f.c")
e26874655738 *: huge refactor, new major release (hahaha)
Paper <paper@tflc.us>
parents: 17
diff changeset
104 set_source_files_properties("src/impl/x86/avx512f.c" PROPERTIES COMPILE_FLAGS "${COMPILER_AVX512F_FLAGS}")
e26874655738 *: huge refactor, new major release (hahaha)
Paper <paper@tflc.us>
parents: 17
diff changeset
105 target_compile_definitions(vec PRIVATE "-DVEC_COMPILER_HAS_AVX512F")
e26874655738 *: huge refactor, new major release (hahaha)
Paper <paper@tflc.us>
parents: 17
diff changeset
106 endif()
e26874655738 *: huge refactor, new major release (hahaha)
Paper <paper@tflc.us>
parents: 17
diff changeset
107
e26874655738 *: huge refactor, new major release (hahaha)
Paper <paper@tflc.us>
parents: 17
diff changeset
108
17
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents: 15
diff changeset
109 #########################################################################
23
e26874655738 *: huge refactor, new major release (hahaha)
Paper <paper@tflc.us>
parents: 17
diff changeset
110 # integer types; it's nice to accommodate for older broken systems that
e26874655738 *: huge refactor, new major release (hahaha)
Paper <paper@tflc.us>
parents: 17
diff changeset
111 # may not have stdint.h.
15
e05c257c6a23 *: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents: 8
diff changeset
112
17
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents: 15
diff changeset
113 include(CheckTypeSize)
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents: 15
diff changeset
114
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents: 15
diff changeset
115 check_type_size("int16_t" INT16_T_SIZE LANGUAGE C)
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents: 15
diff changeset
116 check_type_size("uint16_t" UINT16_T_SIZE LANGUAGE C)
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents: 15
diff changeset
117 check_type_size("u_int16_t" U_INT16_T_SIZE LANGUAGE C)
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents: 15
diff changeset
118 check_type_size("int32_t" INT32_T_SIZE LANGUAGE C)
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents: 15
diff changeset
119 check_type_size("uint32_t" UINT32_T_SIZE LANGUAGE C)
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents: 15
diff changeset
120 check_type_size("u_int32_t" U_INT32_T_SIZE LANGUAGE C)
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents: 15
diff changeset
121 check_type_size("int64_t" INT64_T_SIZE LANGUAGE C)
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents: 15
diff changeset
122 check_type_size("uint64_t" UINT64_T_SIZE LANGUAGE C)
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents: 15
diff changeset
123 check_type_size("u_int64_t" U_INT64_T_SIZE LANGUAGE C)
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents: 15
diff changeset
124 check_type_size("short" SHORT_SIZE LANGUAGE C)
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents: 15
diff changeset
125 check_type_size("int" INT_SIZE LANGUAGE C)
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents: 15
diff changeset
126 check_type_size("long" LONG_SIZE LANGUAGE C)
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents: 15
diff changeset
127 check_type_size("long long" LONG_LONG_SIZE LANGUAGE C)
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents: 15
diff changeset
128 check_type_size("uintptr_t" UINTPTR_T_SIZE LANGUAGE C)
23
e26874655738 *: huge refactor, new major release (hahaha)
Paper <paper@tflc.us>
parents: 17
diff changeset
129 check_type_size("size_t" SIZE_T_SIZE LANGUAGE C)
17
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents: 15
diff changeset
130
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents: 15
diff changeset
131 if(INT16_T_SIZE EQUAL 2)
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents: 15
diff changeset
132 set(SIZE16 "int16_t")
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents: 15
diff changeset
133 elseif(SHORT_SIZE EQUAL 2)
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents: 15
diff changeset
134 set(SIZE16 "short")
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents: 15
diff changeset
135 elseif(INT_SIZE EQUAL 2)
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents: 15
diff changeset
136 set(SIZE16 "int")
23
e26874655738 *: huge refactor, new major release (hahaha)
Paper <paper@tflc.us>
parents: 17
diff changeset
137 else()
e26874655738 *: huge refactor, new major release (hahaha)
Paper <paper@tflc.us>
parents: 17
diff changeset
138 message(FATAL_ERROR "Failed to find a signed 16-bit integer type.")
17
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents: 15
diff changeset
139 endif()
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents: 15
diff changeset
140
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents: 15
diff changeset
141 if(UINT16_T_SIZE EQUAL 2)
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents: 15
diff changeset
142 set(USIZE16 "uint16_t")
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents: 15
diff changeset
143 elseif(U_INT16_T_SIZE EQUAL 2)
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents: 15
diff changeset
144 set(USIZE16 "u_int16_t")
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents: 15
diff changeset
145 elseif(SHORT_SIZE EQUAL 2)
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents: 15
diff changeset
146 set(USIZE16 "unsigned short")
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents: 15
diff changeset
147 elseif(INT_SIZE EQUAL 2)
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents: 15
diff changeset
148 set(USIZE16 "unsigned int")
23
e26874655738 *: huge refactor, new major release (hahaha)
Paper <paper@tflc.us>
parents: 17
diff changeset
149 else()
e26874655738 *: huge refactor, new major release (hahaha)
Paper <paper@tflc.us>
parents: 17
diff changeset
150 message(FATAL_ERROR "Failed to find an unsigned 16-bit integer type.")
17
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents: 15
diff changeset
151 endif()
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents: 15
diff changeset
152
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents: 15
diff changeset
153 if(INT32_T_SIZE EQUAL 4)
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents: 15
diff changeset
154 set(SIZE32 "int32_t")
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents: 15
diff changeset
155 elseif(SHORT_SIZE EQUAL 4)
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents: 15
diff changeset
156 set(SIZE32 "short")
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents: 15
diff changeset
157 elseif(INT_SIZE EQUAL 4)
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents: 15
diff changeset
158 set(SIZE32 "int")
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents: 15
diff changeset
159 elseif(LONG_SIZE EQUAL 4)
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents: 15
diff changeset
160 set(SIZE32 "long")
23
e26874655738 *: huge refactor, new major release (hahaha)
Paper <paper@tflc.us>
parents: 17
diff changeset
161 else()
e26874655738 *: huge refactor, new major release (hahaha)
Paper <paper@tflc.us>
parents: 17
diff changeset
162 message(FATAL_ERROR "Failed to find a signed 32-bit integer type.")
17
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents: 15
diff changeset
163 endif()
8
6e0eb3aa12ab build: add files to build vec as an external library
Paper <paper@tflc.us>
parents:
diff changeset
164
17
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents: 15
diff changeset
165 if(UINT32_T_SIZE EQUAL 4)
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents: 15
diff changeset
166 set(USIZE32 "uint32_t")
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents: 15
diff changeset
167 elseif(U_INT32_T_SIZE EQUAL 4)
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents: 15
diff changeset
168 set(USIZE32 "u_int32_t")
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents: 15
diff changeset
169 elseif(SHORT_SIZE EQUAL 4)
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents: 15
diff changeset
170 set(USIZE32 "unsigned short")
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents: 15
diff changeset
171 elseif(INT_SIZE EQUAL 4)
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents: 15
diff changeset
172 set(USIZE32 "unsigned int")
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents: 15
diff changeset
173 elseif(LONG_SIZE EQUAL 4)
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents: 15
diff changeset
174 set(USIZE32 "unsigned long")
23
e26874655738 *: huge refactor, new major release (hahaha)
Paper <paper@tflc.us>
parents: 17
diff changeset
175 else()
e26874655738 *: huge refactor, new major release (hahaha)
Paper <paper@tflc.us>
parents: 17
diff changeset
176 message(FATAL_ERROR "Failed to find an unsigned 32-bit integer type.")
17
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents: 15
diff changeset
177 endif()
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents: 15
diff changeset
178
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents: 15
diff changeset
179 if(INT64_T_SIZE EQUAL 8)
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents: 15
diff changeset
180 set(SIZE64 "int64_t")
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents: 15
diff changeset
181 elseif(SHORT_SIZE EQUAL 8)
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents: 15
diff changeset
182 set(SIZE64 "short")
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents: 15
diff changeset
183 elseif(INT_SIZE EQUAL 8)
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents: 15
diff changeset
184 set(SIZE64 "int")
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents: 15
diff changeset
185 elseif(LONG_SIZE EQUAL 8)
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents: 15
diff changeset
186 set(SIZE64 "long")
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents: 15
diff changeset
187 elseif(LONG_LONG_SIZE EQUAL 8)
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents: 15
diff changeset
188 set(SIZE64 "long long")
23
e26874655738 *: huge refactor, new major release (hahaha)
Paper <paper@tflc.us>
parents: 17
diff changeset
189 else()
e26874655738 *: huge refactor, new major release (hahaha)
Paper <paper@tflc.us>
parents: 17
diff changeset
190 message(FATAL_ERROR "Failed to find a signed 64-bit integer type.")
17
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents: 15
diff changeset
191 endif()
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents: 15
diff changeset
192
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents: 15
diff changeset
193 if(UINT64_T_SIZE EQUAL 8)
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents: 15
diff changeset
194 set(USIZE64 "uint64_t")
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents: 15
diff changeset
195 elseif(U_INT64_T_SIZE EQUAL 8)
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents: 15
diff changeset
196 set(USIZE64 "u_int64_t")
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents: 15
diff changeset
197 elseif(SHORT_SIZE EQUAL 8)
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents: 15
diff changeset
198 set(USIZE64 "unsigned short")
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents: 15
diff changeset
199 elseif(INT_SIZE EQUAL 8)
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents: 15
diff changeset
200 set(USIZE64 "unsigned int")
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents: 15
diff changeset
201 elseif(LONG_SIZE EQUAL 8)
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents: 15
diff changeset
202 set(USIZE64 "unsigned long")
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents: 15
diff changeset
203 elseif(LONG_LONG_SIZE EQUAL 8)
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents: 15
diff changeset
204 set(USIZE64 "unsigned long long")
23
e26874655738 *: huge refactor, new major release (hahaha)
Paper <paper@tflc.us>
parents: 17
diff changeset
205 else()
e26874655738 *: huge refactor, new major release (hahaha)
Paper <paper@tflc.us>
parents: 17
diff changeset
206 message(FATAL_ERROR "Failed to find an unsigned 64-bit integer type.")
17
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents: 15
diff changeset
207 endif()
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents: 15
diff changeset
208
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents: 15
diff changeset
209 if(CMAKE_SIZEOF_VOID_P EQUAL UINTPTR_T_SIZE)
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents: 15
diff changeset
210 set(USIZEPTR "uintptr_t")
23
e26874655738 *: huge refactor, new major release (hahaha)
Paper <paper@tflc.us>
parents: 17
diff changeset
211 elseif(CMAKE_SIZEOF_VOID_P LESS_EQUAL 1)
17
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents: 15
diff changeset
212 set(USIZEPTR "unsigned char")
23
e26874655738 *: huge refactor, new major release (hahaha)
Paper <paper@tflc.us>
parents: 17
diff changeset
213 elseif(CMAKE_SIZEOF_VOID_P LESS_EQUAL 2)
17
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents: 15
diff changeset
214 set(USIZEPTR "${USIZE16}")
23
e26874655738 *: huge refactor, new major release (hahaha)
Paper <paper@tflc.us>
parents: 17
diff changeset
215 elseif(CMAKE_SIZEOF_VOID_P LESS_EQUAL 4)
17
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents: 15
diff changeset
216 set(USIZEPTR "${USIZE32}")
23
e26874655738 *: huge refactor, new major release (hahaha)
Paper <paper@tflc.us>
parents: 17
diff changeset
217 elseif(CMAKE_SIZEOF_VOID_P LESS_EQUAL 8)
17
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents: 15
diff changeset
218 set(USIZEPTR "${USIZE64}")
23
e26874655738 *: huge refactor, new major release (hahaha)
Paper <paper@tflc.us>
parents: 17
diff changeset
219 else()
e26874655738 *: huge refactor, new major release (hahaha)
Paper <paper@tflc.us>
parents: 17
diff changeset
220 message(FATAL_ERROR "Failed to find an integer type that can fit a pointer.")
17
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents: 15
diff changeset
221 endif()
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents: 15
diff changeset
222
23
e26874655738 *: huge refactor, new major release (hahaha)
Paper <paper@tflc.us>
parents: 17
diff changeset
223 if(NOT SIZE_T_SIZE EQUAL 0 AND NOT SIZE_T_SIZE EQUAL "")
e26874655738 *: huge refactor, new major release (hahaha)
Paper <paper@tflc.us>
parents: 17
diff changeset
224 set(USIZESIZE "size_t")
e26874655738 *: huge refactor, new major release (hahaha)
Paper <paper@tflc.us>
parents: 17
diff changeset
225 else()
e26874655738 *: huge refactor, new major release (hahaha)
Paper <paper@tflc.us>
parents: 17
diff changeset
226 # should be close enough I guess
e26874655738 *: huge refactor, new major release (hahaha)
Paper <paper@tflc.us>
parents: 17
diff changeset
227 set(USIZESIZE "${USIZEPTR}")
e26874655738 *: huge refactor, new major release (hahaha)
Paper <paper@tflc.us>
parents: 17
diff changeset
228 endif()
17
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents: 15
diff changeset
229
23
e26874655738 *: huge refactor, new major release (hahaha)
Paper <paper@tflc.us>
parents: 17
diff changeset
230 configure_file(include/vec/types.h.in include/vec/types.h @ONLY)
17
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents: 15
diff changeset
231
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents: 15
diff changeset
232 #########################################################################
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents: 15
diff changeset
233
23
e26874655738 *: huge refactor, new major release (hahaha)
Paper <paper@tflc.us>
parents: 17
diff changeset
234 target_sources(vec PUBLIC
e26874655738 *: huge refactor, new major release (hahaha)
Paper <paper@tflc.us>
parents: 17
diff changeset
235 $<INSTALL_INTERFACE:vec/vec.h>
e26874655738 *: huge refactor, new major release (hahaha)
Paper <paper@tflc.us>
parents: 17
diff changeset
236 $<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include/vec/vec.h>
e26874655738 *: huge refactor, new major release (hahaha)
Paper <paper@tflc.us>
parents: 17
diff changeset
237 $<INSTALL_INTERFACE:vec/types.h>
e26874655738 *: huge refactor, new major release (hahaha)
Paper <paper@tflc.us>
parents: 17
diff changeset
238 $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include/vec/types.h>
e26874655738 *: huge refactor, new major release (hahaha)
Paper <paper@tflc.us>
parents: 17
diff changeset
239 $<INSTALL_INTERFACE:vec/cpu.h>
e26874655738 *: huge refactor, new major release (hahaha)
Paper <paper@tflc.us>
parents: 17
diff changeset
240 $<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include/vec/cpu.h>
e26874655738 *: huge refactor, new major release (hahaha)
Paper <paper@tflc.us>
parents: 17
diff changeset
241 )
e26874655738 *: huge refactor, new major release (hahaha)
Paper <paper@tflc.us>
parents: 17
diff changeset
242
17
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents: 15
diff changeset
243 target_compile_features(vec PRIVATE $<IF:$<COMPILE_FEATURES:c_std_11>,c_std_11,c_std_99>)
23
e26874655738 *: huge refactor, new major release (hahaha)
Paper <paper@tflc.us>
parents: 17
diff changeset
244 target_include_directories(vec PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include;${CMAKE_CURRENT_BINARY_DIR}/include")
8
6e0eb3aa12ab build: add files to build vec as an external library
Paper <paper@tflc.us>
parents:
diff changeset
245
6e0eb3aa12ab build: add files to build vec as an external library
Paper <paper@tflc.us>
parents:
diff changeset
246 # Installing
6e0eb3aa12ab build: add files to build vec as an external library
Paper <paper@tflc.us>
parents:
diff changeset
247
6e0eb3aa12ab build: add files to build vec as an external library
Paper <paper@tflc.us>
parents:
diff changeset
248 include(GNUInstallDirs)
6e0eb3aa12ab build: add files to build vec as an external library
Paper <paper@tflc.us>
parents:
diff changeset
249
17
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents: 15
diff changeset
250 install(TARGETS vec LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents: 15
diff changeset
251
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents: 15
diff changeset
252 install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/include/vec/vec.h" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/vec")
41dd962abdd1 *: allow compiling vec in a C++ translation unit
Paper <paper@tflc.us>
parents: 15
diff changeset
253 install(FILES "${CMAKE_CURRENT_BINARY_DIR}/include/vec/impl/integer.h" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/vec/impl")
8
6e0eb3aa12ab build: add files to build vec as an external library
Paper <paper@tflc.us>
parents:
diff changeset
254
6e0eb3aa12ab build: add files to build vec as an external library
Paper <paper@tflc.us>
parents:
diff changeset
255 # pkg-config
6e0eb3aa12ab build: add files to build vec as an external library
Paper <paper@tflc.us>
parents:
diff changeset
256 configure_file(vec.pc.in vec.pc @ONLY)
15
e05c257c6a23 *: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents: 8
diff changeset
257 install(FILES ${CMAKE_BINARY_DIR}/vec.pc DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/pkgconfig)