From ae7b063c8a3c97a4ec817d17b737e0f36bacb17d Mon Sep 17 00:00:00 2001 From: SpaceIm <30052553+SpaceIm@users.noreply.github.com> Date: Fri, 16 Jul 2021 00:49:00 +0200 Subject: [PATCH] allow to build either static or shared (#156) also fix shared if msvc Co-authored-by: Veselin Georgiev --- CMakeLists.txt | 7 +++++++ libcpuid/CMakeLists.txt | 7 ++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 912382b..bafae47 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,6 +7,13 @@ project( LANGUAGES C CXX ASM_MASM VERSION ${VERSION}) +if(MSVC) + set(LIBCPUID_SHARED OFF) +else() + set(LIBCPUID_SHARED ON) +endif() +option(BUILD_SHARED_LIBS "Build shared lib" ${LIBCPUID_SHARED}) + option(LIBCPUID_TESTS "Enable building tests" OFF) set(CMAKE_CXX_STANDARD 11) diff --git a/libcpuid/CMakeLists.txt b/libcpuid/CMakeLists.txt index c857e30..8cebc26 100644 --- a/libcpuid/CMakeLists.txt +++ b/libcpuid/CMakeLists.txt @@ -12,11 +12,8 @@ if("${MSVC_CXX_ARCHITECTURE_ID}" MATCHES "x64") list(APPEND cpuid_sources masm-x64.asm) endif() -if(UNIX) - add_library(cpuid SHARED ${cpuid_sources}) -else() - add_library(cpuid ${cpuid_sources}) -endif() +add_library(cpuid ${cpuid_sources}) +set_property(TARGET cpuid PROPERTY WINDOWS_EXPORT_ALL_SYMBOLS ON) target_include_directories(cpuid SYSTEM PUBLIC $) target_compile_definitions(cpuid PRIVATE VERSION="${PROJECT_VERSION}")