mirror of
https://github.com/anrieff/libcpuid
synced 2024-12-16 16:35:45 +00:00
CMake: harmonizes options
This commit is contained in:
parent
4d6cc787fe
commit
52efefbb7d
5 changed files with 58 additions and 40 deletions
|
@ -17,9 +17,11 @@ if(MSVC)
|
|||
else()
|
||||
set(LIBCPUID_SHARED ON)
|
||||
endif()
|
||||
option(BUILD_SHARED_LIBS "Build shared lib" ${LIBCPUID_SHARED})
|
||||
option(LIBCPUID_DRIVERS "Enable kernel drivers" ON)
|
||||
option(LIBCPUID_TESTS "Enable building tests" OFF)
|
||||
|
||||
# Options
|
||||
option(BUILD_SHARED_LIBS "Build building shared libraries" ${LIBCPUID_SHARED})
|
||||
option(LIBCPUID_BUILD_DRIVERS "Enable building kernel drivers" ON)
|
||||
option(LIBCPUID_ENABLE_TESTS "Enable tests targets" OFF)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 11)
|
||||
set(CMAKE_C_STANDARD 99)
|
||||
|
@ -65,9 +67,9 @@ endif(UNIX)
|
|||
# Include subdirectories
|
||||
add_subdirectory(libcpuid)
|
||||
add_subdirectory(cpuid_tool)
|
||||
if(LIBCPUID_DRIVERS)
|
||||
if(LIBCPUID_BUILD_DRIVERS)
|
||||
add_subdirectory(drivers)
|
||||
endif()
|
||||
if(LIBCPUID_TESTS)
|
||||
endif(LIBCPUID_BUILD_DRIVERS)
|
||||
if(LIBCPUID_ENABLE_TESTS)
|
||||
add_subdirectory(tests)
|
||||
endif()
|
||||
endif(LIBCPUID_ENABLE_TESTS)
|
||||
|
|
10
Readme.md
10
Readme.md
|
@ -65,9 +65,17 @@ sources.
|
|||
|
||||
##### By using CMake
|
||||
|
||||
CMake options for libcpuid (use `cmake -LH` to list all options):
|
||||
- `LIBCPUID_ENABLE_DOCS`: enable building documentation by using Doxyen (**ON** by default)
|
||||
- `LIBCPUID_ENABLE_TESTS`: enable tests targets, like `test-fast`, `test-old` and `fix-tests` (**OFF** by default)
|
||||
- `LIBCPUID_BUILD_DEPRECATED`: build support of deprecated attributes (**ON** by default to guarantee backward compatibility)
|
||||
- `LIBCPUID_BUILD_DRIVERS`: enable building kernel drivers (**ON** by default)
|
||||
- `LIBCPUID_DRIVER_DEBUG`: enable debug mode flr kernel drivers (**OFF** by default)
|
||||
- `LIBCPUID_DRIVER_ARM_LINUX_DKMS`: use DKMS for CPUID Linux kernel module for ARM (**ON** by default), switch off to build the kernel module in the `build` directory
|
||||
|
||||
Basic example to build and install libcpuid by using CMake:
|
||||
```shell
|
||||
cmake -S . -B build -DCMAKE_BUILD_TYPE=RelWithDebInfo
|
||||
cmake -S . -B build -DCMAKE_BUILD_TYPE=RelWithDebInfo -DLIBCPUID_ENABLE_TESTS=ON
|
||||
cmake --build build
|
||||
cmake --install build # may need administrative privileges, install under /usr/local by default
|
||||
```
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
option(LIBCPUID_DRIVER_DEBUG "Debug kernel module" OFF)
|
||||
# Options
|
||||
option(LIBCPUID_DRIVER_DEBUG "Debug kernel driver" OFF)
|
||||
|
||||
if(LIBCPUID_DRIVER_DEBUG)
|
||||
add_definitions(-DLIBCPUID_DRIVER_DEBUG)
|
||||
endif(LIBCPUID_DRIVER_DEBUG)
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
set(DRIVER_NAME "cpuid")
|
||||
# Options
|
||||
option(LIBCPUID_DRIVER_ARM_LINUX_DKMS "Use DKMS for CPUID kernel module for ARM" ON)
|
||||
|
||||
set(DRIVER_NAME "cpuid")
|
||||
|
||||
if(LIBCPUID_DRIVER_ARM_LINUX_DKMS)
|
||||
message(STATUS "Deploying DKMS configuration for CPUID kernel module...")
|
||||
set(LIBCPUID_SRC_DIR "/usr/src/${CMAKE_PROJECT_NAME}-${PROJECT_VERSION}")
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
# Options
|
||||
option(LIBCPUID_BUILD_DEPRECATED "Build support of deprecated attributes" ON)
|
||||
option(LIBCPUID_ENABLE_DOCS "Enable building documentation" ON)
|
||||
|
||||
set(cpuid_sources
|
||||
cpuid_main.c
|
||||
recog_amd.c
|
||||
|
@ -21,11 +25,10 @@ if("${MSVC_CXX_ARCHITECTURE_ID}" MATCHES "x64")
|
|||
list(APPEND cpuid_sources masm-x64.asm)
|
||||
endif()
|
||||
|
||||
option(SUPPORT_DEPRECATED "Build support of deprecated attributes" ON)
|
||||
if(NOT SUPPORT_DEPRECATED)
|
||||
if(NOT LIBCPUID_BUILD_DEPRECATED)
|
||||
message(AUTHOR_WARNING "Deprecated attributes will not be available, the library will be not backward compatible")
|
||||
add_compile_definitions(LIBCPUID_DISABLE_DEPRECATED)
|
||||
endif(NOT SUPPORT_DEPRECATED)
|
||||
endif(NOT LIBCPUID_BUILD_DEPRECATED)
|
||||
|
||||
add_library(cpuid ${cpuid_sources})
|
||||
set_property(TARGET cpuid PROPERTY WINDOWS_EXPORT_ALL_SYMBOLS ON)
|
||||
|
@ -38,9 +41,9 @@ set_target_properties(cpuid PROPERTIES SOVERSION "${LIBCPUID_CURRENT}")
|
|||
set_target_properties(cpuid PROPERTIES PUBLIC_HEADER "libcpuid.h;libcpuid_types.h;libcpuid_constants.h")
|
||||
|
||||
# Documentation
|
||||
if(LIBCPUID_ENABLE_DOCS)
|
||||
find_package(Doxygen)
|
||||
option(ENABLE_DOCS "Enable building documentation." ON)
|
||||
if(DOXYGEN_FOUND AND ENABLE_DOCS)
|
||||
if(DOXYGEN_FOUND)
|
||||
set(top_srcdir ${PROJECT_SOURCE_DIR})
|
||||
configure_file(Doxyfile.in Doxyfile ESCAPE_QUOTES)
|
||||
add_custom_target(
|
||||
|
@ -58,13 +61,14 @@ if(DOXYGEN_FOUND AND ENABLE_DOCS)
|
|||
PATTERN "libcpuid.3"
|
||||
PATTERN "cpuid_tool.3")
|
||||
endif(UNIX)
|
||||
else()
|
||||
else(DOXYGEN_FOUND)
|
||||
add_custom_target(
|
||||
docs
|
||||
echo
|
||||
"Doxygen was not installed when CMake was run or ENABLE_DOCS was OFF. Check that Doxygen is installed and rerun `cmake .`"
|
||||
"Doxygen was not installed when CMake was run. Check that Doxygen is installed and rerun `cmake .`"
|
||||
VERBATIM)
|
||||
endif()
|
||||
endif(DOXYGEN_FOUND)
|
||||
endif(LIBCPUID_ENABLE_DOCS)
|
||||
|
||||
# Configuration
|
||||
set(generated_dir "${CMAKE_CURRENT_BINARY_DIR}/generated")
|
||||
|
|
Loading…
Reference in a new issue