Commit 2e8f883a authored by Anonymous Maarten's avatar Anonymous Maarten

cmake: use target properties to define shared/static defines

By applying them on the target, these are also available in the
installed libconfigConfig.cmake scripts
parent beab799a
......@@ -20,14 +20,6 @@ set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/out)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/out)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/out)
if(BUILD_SHARED_LIBS)
add_definitions(-DLIBCONFIG_EXPORTS)
add_definitions(-DLIBCONFIGXX_EXPORTS)
else()
add_definitions(-DLIBCONFIG_STATIC)
add_definitions(-DLIBCONFIGXX_STATIC)
endif()
include(GNUInstallDirs)
include(CheckSymbolExists)
add_subdirectory(lib)
......
......@@ -28,7 +28,7 @@ set(libsrc_cpp
${libsrc}
libconfigcpp.cc)
if(CMAKE_HOST_WIN32)
if(MSVC)
set(libname "libconfig")
else()
set(libname "config")
......@@ -41,10 +41,12 @@ set_target_properties(${libname}
PROPERTIES LINKER_LANGUAGE C
SOVERSION "${libconfig_VERSION_MAJOR}"
VERSION "${libconfig_VERSION}"
DEFINE_SYMBOL LIBCONFIG_EXPORTS
PUBLIC_HEADER "${libinc}")
set_target_properties(${libname}++
PROPERTIES LINKER_LANGUAGE CXX
SOVERSION "${libconfig_VERSION_MAJOR}"
DEFINE_SYMBOL LIBCONFIGXX_EXPORTS
VERSION "${libconfig_VERSION}"
PUBLIC_HEADER "${libinc_cpp}")
......@@ -52,6 +54,13 @@ set_target_properties(${libname}++
#check_symbol_exists(newlocale "locale.h" HAVE_NEWLOCALE)
#check_symbol_exists(freelocale "locale.h" HAVE_FREELOCALE)
if(BUILD_SHARED_LIBS)
target_compile_definitions(${libname}++ PRIVATE LIBCONFIG_STATIC)
else()
target_compile_definitions(${libname} PUBLIC LIBCONFIG_STATIC)
target_compile_definitions(${libname}++ PUBLIC LIBCONFIGXX_STATIC)
endif()
if(HAVE_USELOCALE)
target_compile_definitions(${libname}
PRIVATE "HAVE_USELOCALE")
......@@ -67,21 +76,23 @@ target_compile_definitions(${libname}
PRIVATE "HAVE_FREELOCALE")
endif()
target_compile_definitions(${libname}
PRIVATE
_CRT_SECURE_NO_DEPRECATE
YY_NO_UNISTD_H
YY_USE_CONST )
target_compile_definitions(${libname}++
PRIVATE
_CRT_SECURE_NO_DEPRECATE
YY_NO_UNISTD_H
YY_USE_CONST )
if(CMAKE_HOST_WIN32)
target_link_libraries(${libname} Shlwapi.lib)
target_link_libraries(${libname}++ Shlwapi.lib)
if(MSVC)
target_compile_definitions(${libname}
PRIVATE
_CRT_SECURE_NO_DEPRECATE
YY_NO_UNISTD_H
YY_USE_CONST )
target_compile_definitions(${libname}++
PRIVATE
_CRT_SECURE_NO_DEPRECATE
YY_NO_UNISTD_H
YY_USE_CONST )
endif()
if(WIN32)
target_link_libraries(${libname} shlwapi)
target_link_libraries(${libname}++ shlwapi)
endif()
target_include_directories(${libname}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment