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()
|
else()
|
||||||
set(LIBCPUID_SHARED ON)
|
set(LIBCPUID_SHARED ON)
|
||||||
endif()
|
endif()
|
||||||
option(BUILD_SHARED_LIBS "Build shared lib" ${LIBCPUID_SHARED})
|
|
||||||
option(LIBCPUID_DRIVERS "Enable kernel drivers" ON)
|
# Options
|
||||||
option(LIBCPUID_TESTS "Enable building tests" OFF)
|
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_CXX_STANDARD 11)
|
||||||
set(CMAKE_C_STANDARD 99)
|
set(CMAKE_C_STANDARD 99)
|
||||||
|
@ -65,9 +67,9 @@ endif(UNIX)
|
||||||
# Include subdirectories
|
# Include subdirectories
|
||||||
add_subdirectory(libcpuid)
|
add_subdirectory(libcpuid)
|
||||||
add_subdirectory(cpuid_tool)
|
add_subdirectory(cpuid_tool)
|
||||||
if(LIBCPUID_DRIVERS)
|
if(LIBCPUID_BUILD_DRIVERS)
|
||||||
add_subdirectory(drivers)
|
add_subdirectory(drivers)
|
||||||
endif()
|
endif(LIBCPUID_BUILD_DRIVERS)
|
||||||
if(LIBCPUID_TESTS)
|
if(LIBCPUID_ENABLE_TESTS)
|
||||||
add_subdirectory(tests)
|
add_subdirectory(tests)
|
||||||
endif()
|
endif(LIBCPUID_ENABLE_TESTS)
|
||||||
|
|
10
Readme.md
10
Readme.md
|
@ -65,9 +65,17 @@ sources.
|
||||||
|
|
||||||
##### By using CMake
|
##### 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:
|
Basic example to build and install libcpuid by using CMake:
|
||||||
```shell
|
```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 --build build
|
||||||
cmake --install build # may need administrative privileges, install under /usr/local by default
|
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)
|
if(LIBCPUID_DRIVER_DEBUG)
|
||||||
add_definitions(-DLIBCPUID_DRIVER_DEBUG)
|
add_definitions(-DLIBCPUID_DRIVER_DEBUG)
|
||||||
endif(LIBCPUID_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)
|
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)
|
if(LIBCPUID_DRIVER_ARM_LINUX_DKMS)
|
||||||
message(STATUS "Deploying DKMS configuration for CPUID kernel module...")
|
message(STATUS "Deploying DKMS configuration for CPUID kernel module...")
|
||||||
set(LIBCPUID_SRC_DIR "/usr/src/${CMAKE_PROJECT_NAME}-${PROJECT_VERSION}")
|
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
|
set(cpuid_sources
|
||||||
cpuid_main.c
|
cpuid_main.c
|
||||||
recog_amd.c
|
recog_amd.c
|
||||||
|
@ -21,11 +25,10 @@ if("${MSVC_CXX_ARCHITECTURE_ID}" MATCHES "x64")
|
||||||
list(APPEND cpuid_sources masm-x64.asm)
|
list(APPEND cpuid_sources masm-x64.asm)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
option(SUPPORT_DEPRECATED "Build support of deprecated attributes" ON)
|
if(NOT LIBCPUID_BUILD_DEPRECATED)
|
||||||
if(NOT SUPPORT_DEPRECATED)
|
|
||||||
message(AUTHOR_WARNING "Deprecated attributes will not be available, the library will be not backward compatible")
|
message(AUTHOR_WARNING "Deprecated attributes will not be available, the library will be not backward compatible")
|
||||||
add_compile_definitions(LIBCPUID_DISABLE_DEPRECATED)
|
add_compile_definitions(LIBCPUID_DISABLE_DEPRECATED)
|
||||||
endif(NOT SUPPORT_DEPRECATED)
|
endif(NOT LIBCPUID_BUILD_DEPRECATED)
|
||||||
|
|
||||||
add_library(cpuid ${cpuid_sources})
|
add_library(cpuid ${cpuid_sources})
|
||||||
set_property(TARGET cpuid PROPERTY WINDOWS_EXPORT_ALL_SYMBOLS ON)
|
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")
|
set_target_properties(cpuid PROPERTIES PUBLIC_HEADER "libcpuid.h;libcpuid_types.h;libcpuid_constants.h")
|
||||||
|
|
||||||
# Documentation
|
# Documentation
|
||||||
find_package(Doxygen)
|
if(LIBCPUID_ENABLE_DOCS)
|
||||||
option(ENABLE_DOCS "Enable building documentation." ON)
|
find_package(Doxygen)
|
||||||
if(DOXYGEN_FOUND AND ENABLE_DOCS)
|
if(DOXYGEN_FOUND)
|
||||||
set(top_srcdir ${PROJECT_SOURCE_DIR})
|
set(top_srcdir ${PROJECT_SOURCE_DIR})
|
||||||
configure_file(Doxyfile.in Doxyfile ESCAPE_QUOTES)
|
configure_file(Doxyfile.in Doxyfile ESCAPE_QUOTES)
|
||||||
add_custom_target(
|
add_custom_target(
|
||||||
|
@ -58,13 +61,14 @@ if(DOXYGEN_FOUND AND ENABLE_DOCS)
|
||||||
PATTERN "libcpuid.3"
|
PATTERN "libcpuid.3"
|
||||||
PATTERN "cpuid_tool.3")
|
PATTERN "cpuid_tool.3")
|
||||||
endif(UNIX)
|
endif(UNIX)
|
||||||
else()
|
else(DOXYGEN_FOUND)
|
||||||
add_custom_target(
|
add_custom_target(
|
||||||
docs
|
docs
|
||||||
echo
|
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)
|
VERBATIM)
|
||||||
endif()
|
endif(DOXYGEN_FOUND)
|
||||||
|
endif(LIBCPUID_ENABLE_DOCS)
|
||||||
|
|
||||||
# Configuration
|
# Configuration
|
||||||
set(generated_dir "${CMAKE_CURRENT_BINARY_DIR}/generated")
|
set(generated_dir "${CMAKE_CURRENT_BINARY_DIR}/generated")
|
||||||
|
|
Loading…
Reference in a new issue