Skip to content

Commit 87e5f0b

Browse files
CMake updates (#302)
* Add BUILD_SHARED_LIBS option to choose between shared and static lib * Fix build break for Android aarch64 * Install built target * Set the correct version number * Don't add include dirs through CFlags. Include dirs are already set as target property * Install all relevant headers, not just from include dir * Update note about BUILD_SHARED_LIBS in README.md * Fix mistake in README.md, option(BUILD_SHARED_LIBS ON) sets the lib to shared by default
1 parent d9f2b0f commit 87e5f0b

File tree

2 files changed

+11
-12
lines changed

2 files changed

+11
-12
lines changed

CMakeLists.txt

+8-10
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
11
cmake_minimum_required(VERSION 3.25)
22

33
project(openlibm
4-
VERSION 0.8.0
4+
VERSION 0.8.2
55
LANGUAGES C ASM)
66

7-
add_library("${PROJECT_NAME}" SHARED)
7+
option(BUILD_SHARED_LIBS "Build using shared libraries" ON)
88

9+
add_library("${PROJECT_NAME}")
910

1011
# Find the relevant folder depending on the architecture
1112
set(OPENLIBM_ARCH_FOLDER ${CMAKE_SYSTEM_PROCESSOR})
1213
string(TOLOWER "${OPENLIBM_ARCH_FOLDER}" OPENLIBM_ARCH_FOLDER)
1314

1415
if(${OPENLIBM_ARCH_FOLDER} STREQUAL "amd64" OR ${OPENLIBM_ARCH_FOLDER} STREQUAL "x86_64")
1516
set(OPENLIBM_ARCH_FOLDER "amd64")
16-
elseif(${OPENLIBM_ARCH_FOLDER} MATCHES "arm64")
17+
elseif(${OPENLIBM_ARCH_FOLDER} STREQUAL "arm64" OR ${OPENLIBM_ARCH_FOLDER} STREQUAL "aarch64")
1718
set(OPENLIBM_ARCH_FOLDER "aarch64")
1819
elseif(${OPENLIBM_ARCH_FOLDER} STREQUAL "x86")
1920
set(OPENLIBM_ARCH_FOLDER "i387")
@@ -51,13 +52,6 @@ if(OPENLIBM_SUPPRESS_WARNINGS)
5152
list(APPEND C_ASM_COMPILE_FLAGS "-w")
5253
endif()
5354

54-
list(APPEND C_ASM_COMPILE_FLAGS
55-
"-I${PROJECT_SRC}"
56-
"-I${PROJECT_SRC}/include"
57-
"-I${PROJECT_SRC}/${OPENLIBM_ARCH_FOLDER}"
58-
"-I${PROJECT_SRC}/src"
59-
)
60-
6155
# Add compile flags
6256
target_compile_options("${PROJECT_NAME}" PUBLIC ${C_ASM_COMPILE_FLAGS})
6357

@@ -547,3 +541,7 @@ else()
547541
endif()
548542

549543
target_include_directories("${PROJECT_NAME}" PUBLIC ${OPENLIBM_INCLUDE_DIRS})
544+
545+
file(GLOB PUBLIC_HEADERS "*.h" "include/*.h" "${OPENLIBM_ARCH_FOLDER}/*.h" "src/*.h")
546+
set_target_properties("${PROJECT_NAME}" PROPERTIES PUBLIC_HEADER "${PUBLIC_HEADERS}")
547+
install (TARGETS "${PROJECT_NAME}")

README.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,9 @@ qemu-$ARCH-static -L . -L /usr/$TRIPLE/ test/test-double
6161
or generate project with build system of choice e.g. `cmake /path/to/openlib/ -G "MinGW Makefiles"`.
6262
3. Build with the build system with `cmake --build .`.
6363

64-
Default CMake configuration builds a shared library, this can easily be changed by replacing
65-
the keyword in the `add_library()` command in the `CMakeLists.txt`.
64+
Default CMake configuration builds a shared library, this can easily be configured using
65+
[BUILD_SHARED_LIBS](https://cmake.org/cmake/help/latest/variable/BUILD_SHARED_LIBS.html)
66+
configuration option.
6667

6768

6869
## Acknowledgements

0 commit comments

Comments
 (0)