Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CMake updates #302

Merged
merged 8 commits into from
Jun 19, 2024
18 changes: 8 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
cmake_minimum_required(VERSION 3.25)

project(openlibm
VERSION 0.8.0
VERSION 0.8.2
LANGUAGES C ASM)

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

add_library("${PROJECT_NAME}")

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

if(${OPENLIBM_ARCH_FOLDER} STREQUAL "amd64" OR ${OPENLIBM_ARCH_FOLDER} STREQUAL "x86_64")
set(OPENLIBM_ARCH_FOLDER "amd64")
elseif(${OPENLIBM_ARCH_FOLDER} MATCHES "arm64")
elseif(${OPENLIBM_ARCH_FOLDER} STREQUAL "arm64" OR ${OPENLIBM_ARCH_FOLDER} STREQUAL "aarch64")
set(OPENLIBM_ARCH_FOLDER "aarch64")
elseif(${OPENLIBM_ARCH_FOLDER} STREQUAL "x86")
set(OPENLIBM_ARCH_FOLDER "i387")
Expand Down Expand Up @@ -51,13 +52,6 @@ if(OPENLIBM_SUPPRESS_WARNINGS)
list(APPEND C_ASM_COMPILE_FLAGS "-w")
endif()

list(APPEND C_ASM_COMPILE_FLAGS
"-I${PROJECT_SRC}"
"-I${PROJECT_SRC}/include"
"-I${PROJECT_SRC}/${OPENLIBM_ARCH_FOLDER}"
"-I${PROJECT_SRC}/src"
)

# Add compile flags
target_compile_options("${PROJECT_NAME}" PUBLIC ${C_ASM_COMPILE_FLAGS})

Expand Down Expand Up @@ -547,3 +541,7 @@ else()
endif()

target_include_directories("${PROJECT_NAME}" PUBLIC ${OPENLIBM_INCLUDE_DIRS})

file(GLOB PUBLIC_HEADERS "*.h" "include/*.h" "${OPENLIBM_ARCH_FOLDER}/*.h" "src/*.h")
set_target_properties("${PROJECT_NAME}" PROPERTIES PUBLIC_HEADER "${PUBLIC_HEADERS}")
install (TARGETS "${PROJECT_NAME}")
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,9 @@ qemu-$ARCH-static -L . -L /usr/$TRIPLE/ test/test-double
or generate project with build system of choice e.g. `cmake /path/to/openlib/ -G "MinGW Makefiles"`.
3. Build with the build system with `cmake --build .`.

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


## Acknowledgements
Expand Down
Loading