Unverified Commit 0e7bf4d1 authored by Mark Lindner's avatar Mark Lindner Committed by GitHub

Merge pull request #128 from erstrom/fix-library-name-on-linux

cmake: remove lib prefix when building for non windows hosts
parents 6ef3723c f8dd13ea
if(CMAKE_HOST_WIN32)
set(libname "libconfig")
else()
set(libname "config")
endif()
add_executable(c++_example1 example1.cpp )
add_executable(c++_example2 example2.cpp )
add_executable(c++_example3 example3.cpp )
......@@ -8,7 +14,7 @@ target_include_directories(c++_example2 PRIVATE ${CMAKE_SOURCE_DIR}/lib)
target_include_directories(c++_example3 PRIVATE ${CMAKE_SOURCE_DIR}/lib)
target_include_directories(c++_example4 PRIVATE ${CMAKE_SOURCE_DIR}/lib)
target_link_libraries(c++_example1 libconfig++ )
target_link_libraries(c++_example2 libconfig++ )
target_link_libraries(c++_example3 libconfig++ )
target_link_libraries(c++_example4 libconfig++ )
\ No newline at end of file
target_link_libraries(c++_example1 ${libname}++ )
target_link_libraries(c++_example2 ${libname}++ )
target_link_libraries(c++_example3 ${libname}++ )
target_link_libraries(c++_example4 ${libname}++ )
if(CMAKE_HOST_WIN32)
set(libname "libconfig")
else()
set(libname "config")
endif()
add_executable(c_example1 example1.c )
add_executable(c_example2 example2.c )
add_executable(c_example3 example3.c )
......@@ -6,6 +12,6 @@ target_include_directories(c_example1 PRIVATE ${CMAKE_SOURCE_DIR}/lib)
target_include_directories(c_example2 PRIVATE ${CMAKE_SOURCE_DIR}/lib)
target_include_directories(c_example3 PRIVATE ${CMAKE_SOURCE_DIR}/lib)
target_link_libraries(c_example1 libconfig )
target_link_libraries(c_example2 libconfig )
target_link_libraries(c_example3 libconfig )
\ No newline at end of file
target_link_libraries(c_example1 ${libname} )
target_link_libraries(c_example2 ${libname} )
target_link_libraries(c_example3 ${libname} )
......@@ -28,41 +28,47 @@ set(libsrc_cpp
${libsrc}
libconfigcpp.cc)
add_library(libconfig ${libsrc} ${libinc})
add_library(libconfig++ ${libsrc_cpp} ${libinc_cpp})
if(CMAKE_HOST_WIN32)
set(libname "libconfig")
else()
set(libname "config")
endif()
add_library(${libname} ${libsrc} ${libinc})
add_library(${libname}++ ${libsrc_cpp} ${libinc_cpp})
set_target_properties(libconfig
set_target_properties(${libname}
PROPERTIES LINKER_LANGUAGE C
PUBLIC_HEADER "${libinc}")
set_target_properties(libconfig++
set_target_properties(${libname}++
PROPERTIES LINKER_LANGUAGE CXX
PUBLIC_HEADER "${libinc_cpp}")
target_compile_definitions(libconfig
target_compile_definitions(${libname}
PRIVATE
_CRT_SECURE_NO_DEPRECATE
YY_NO_UNISTD_H
YY_USE_CONST )
target_compile_definitions(libconfig++
target_compile_definitions(${libname}++
PRIVATE
_CRT_SECURE_NO_DEPRECATE
YY_NO_UNISTD_H
YY_USE_CONST )
if(CMAKE_HOST_WIN32)
target_link_libraries(libconfig Shlwapi.lib)
target_link_libraries(libconfig++ Shlwapi.lib)
target_link_libraries(${libname} Shlwapi.lib)
target_link_libraries(${libname}++ Shlwapi.lib)
endif()
install(TARGETS libconfig
install(TARGETS ${libname}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)
install(TARGETS libconfig++
install(TARGETS ${libname}++
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
......
if(CMAKE_HOST_WIN32)
set(libname "libconfig")
else()
set(libname "config")
endif()
add_executable(libconfig_tests
tests.c
)
target_link_libraries(libconfig_tests
libconfig
${libname}
libtinytest
)
......
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