Mercurial > vec
annotate CMakeLists.txt @ 16:9da2aba90c87
pkgconfig: -DVEC_EXTERN is no longer required
author | Paper <paper@tflc.us> |
---|---|
date | Wed, 20 Nov 2024 04:16:56 -0500 |
parents | e05c257c6a23 |
children | 41dd962abdd1 |
rev | line source |
---|---|
8
6e0eb3aa12ab
build: add files to build vec as an external library
Paper <paper@tflc.us>
parents:
diff
changeset
|
1 cmake_minimum_required(VERSION 3.5) |
6e0eb3aa12ab
build: add files to build vec as an external library
Paper <paper@tflc.us>
parents:
diff
changeset
|
2 |
15
e05c257c6a23
*: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents:
8
diff
changeset
|
3 project(vec VERSION 2.0.0 DESCRIPTION "a tiny C99 SIMD vector library") |
8
6e0eb3aa12ab
build: add files to build vec as an external library
Paper <paper@tflc.us>
parents:
diff
changeset
|
4 |
6e0eb3aa12ab
build: add files to build vec as an external library
Paper <paper@tflc.us>
parents:
diff
changeset
|
5 add_library(vec SHARED src/vec.c) |
6e0eb3aa12ab
build: add files to build vec as an external library
Paper <paper@tflc.us>
parents:
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) |
e05c257c6a23
*: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents:
8
diff
changeset
|
10 # TODO ? |
e05c257c6a23
*: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents:
8
diff
changeset
|
11 else() |
e05c257c6a23
*: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents:
8
diff
changeset
|
12 check_c_compiler_flag("-maltivec" COMPILER_HAS_ALTIVEC) |
e05c257c6a23
*: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents:
8
diff
changeset
|
13 if(COMPILER_HAS_ALTIVEC) |
e05c257c6a23
*: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents:
8
diff
changeset
|
14 target_compile_options(vec PRIVATE "-maltivec") |
e05c257c6a23
*: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents:
8
diff
changeset
|
15 endif() |
e05c257c6a23
*: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents:
8
diff
changeset
|
16 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
|
17 if(COMPILER_HAS_MMX) |
e05c257c6a23
*: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents:
8
diff
changeset
|
18 target_compile_options(vec PRIVATE "-mmmx") |
e05c257c6a23
*: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents:
8
diff
changeset
|
19 endif() |
e05c257c6a23
*: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents:
8
diff
changeset
|
20 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
|
21 if(COMPILER_HAS_SSE2) |
e05c257c6a23
*: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents:
8
diff
changeset
|
22 target_compile_options(vec PRIVATE "-msse2") |
e05c257c6a23
*: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents:
8
diff
changeset
|
23 endif() |
e05c257c6a23
*: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents:
8
diff
changeset
|
24 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
|
25 if(COMPILER_HAS_SSE41) |
e05c257c6a23
*: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents:
8
diff
changeset
|
26 target_compile_options(vec PRIVATE "-msse4.1") |
e05c257c6a23
*: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents:
8
diff
changeset
|
27 endif() |
e05c257c6a23
*: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents:
8
diff
changeset
|
28 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
|
29 if(COMPILER_HAS_AVX2) |
e05c257c6a23
*: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents:
8
diff
changeset
|
30 target_compile_options(vec PRIVATE "-mavx2") |
e05c257c6a23
*: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents:
8
diff
changeset
|
31 endif() |
e05c257c6a23
*: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents:
8
diff
changeset
|
32 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
|
33 if(COMPILER_HAS_AVX512F) |
e05c257c6a23
*: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents:
8
diff
changeset
|
34 target_compile_options(vec PRIVATE "-mavx512f") |
e05c257c6a23
*: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents:
8
diff
changeset
|
35 endif() |
e05c257c6a23
*: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents:
8
diff
changeset
|
36 endif() |
e05c257c6a23
*: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents:
8
diff
changeset
|
37 |
e05c257c6a23
*: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents:
8
diff
changeset
|
38 |
e05c257c6a23
*: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents:
8
diff
changeset
|
39 set_target_properties(vec PROPERTIES PUBLIC_HEADER include/vec/vec.h C_STANDARD 99) |
8
6e0eb3aa12ab
build: add files to build vec as an external library
Paper <paper@tflc.us>
parents:
diff
changeset
|
40 |
6e0eb3aa12ab
build: add files to build vec as an external library
Paper <paper@tflc.us>
parents:
diff
changeset
|
41 target_include_directories(vec PRIVATE include) |
6e0eb3aa12ab
build: add files to build vec as an external library
Paper <paper@tflc.us>
parents:
diff
changeset
|
42 |
6e0eb3aa12ab
build: add files to build vec as an external library
Paper <paper@tflc.us>
parents:
diff
changeset
|
43 # Installing |
6e0eb3aa12ab
build: add files to build vec as an external library
Paper <paper@tflc.us>
parents:
diff
changeset
|
44 |
6e0eb3aa12ab
build: add files to build vec as an external library
Paper <paper@tflc.us>
parents:
diff
changeset
|
45 include(GNUInstallDirs) |
6e0eb3aa12ab
build: add files to build vec as an external library
Paper <paper@tflc.us>
parents:
diff
changeset
|
46 |
6e0eb3aa12ab
build: add files to build vec as an external library
Paper <paper@tflc.us>
parents:
diff
changeset
|
47 install(TARGETS vec |
15
e05c257c6a23
*: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents:
8
diff
changeset
|
48 LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} |
e05c257c6a23
*: huge refactor, add many new x86 intrinsics and the like
Paper <paper@tflc.us>
parents:
8
diff
changeset
|
49 PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) |
8
6e0eb3aa12ab
build: add files to build vec as an external library
Paper <paper@tflc.us>
parents:
diff
changeset
|
50 |
6e0eb3aa12ab
build: add files to build vec as an external library
Paper <paper@tflc.us>
parents:
diff
changeset
|
51 # pkg-config |
6e0eb3aa12ab
build: add files to build vec as an external library
Paper <paper@tflc.us>
parents:
diff
changeset
|
52 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
|
53 install(FILES ${CMAKE_BINARY_DIR}/vec.pc DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/pkgconfig) |