aboutsummaryrefslogtreecommitdiffstats
path: root/cmake
diff options
context:
space:
mode:
authorMauro Sardara <msardara@cisco.com>2019-03-11 19:19:15 +0100
committerMauro Sardara <msardara@cisco.com>2019-03-12 11:04:38 +0100
commite1dbbf7e8e0b2d5101aa4e06d90f82cfab5087d2 (patch)
treeeb7ecbc11044255e7f0a6508d746024f956fc273 /cmake
parentf14470a4e352b15aea76a8c6176c409c595cf534 (diff)
[HICN-106]
Added generation of .lib for dll shared libraries fixed warning for shift in csum_fold function in libhicn added declaration of external symbol in libtransport log. Change-Id: I9377eb6016a74f14eb8f05df2ced36ee41a27bfd Signed-off-by: Mauro Sardara <msardara@cisco.com>
Diffstat (limited to 'cmake')
-rw-r--r--cmake/Modules/BuildMacros.cmake53
1 files changed, 37 insertions, 16 deletions
diff --git a/cmake/Modules/BuildMacros.cmake b/cmake/Modules/BuildMacros.cmake
index 474026d1d..0908189b5 100644
--- a/cmake/Modules/BuildMacros.cmake
+++ b/cmake/Modules/BuildMacros.cmake
@@ -23,10 +23,19 @@ macro(build_executable exec)
${ARGN}
)
- set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
- set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
-
add_executable(${exec} ${ARG_SOURCES})
+
+ set(BUILD_ROOT ${CMAKE_BINARY_DIR}/build-root)
+
+ set_target_properties(${exec}
+ PROPERTIES
+ INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib"
+ INSTALL_RPATH_USE_LINK_PATH TRUE
+ ARCHIVE_OUTPUT_DIRECTORY "${BUILD_ROOT}/lib"
+ LIBRARY_OUTPUT_DIRECTORY "${BUILD_ROOT}/lib"
+ RUNTIME_OUTPUT_DIRECTORY "${BUILD_ROOT}/bin"
+ )
+
if(ARG_LINK_LIBRARIES)
target_link_libraries(${exec} ${ARG_LINK_LIBRARIES})
endif()
@@ -47,7 +56,7 @@ macro(build_executable exec)
endif()
if(NOT ARG_NO_INSTALL)
- install(TARGETS ${exec} DESTINATION bin COMPONENT ${ARG_COMPONENT})
+ install(TARGETS ${exec} RUNTIME DESTINATION bin COMPONENT ${ARG_COMPONENT})
endif()
endmacro()
@@ -59,9 +68,6 @@ macro(build_library lib)
${ARGN}
)
- set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
- set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
-
if (ARG_SHARED)
list(APPEND TARGET_LIBS
${lib}.shared
@@ -76,18 +82,13 @@ macro(build_library lib)
add_library(${lib} STATIC ${ARG_SOURCES})
endif()
- # install .so
if(NOT ARG_COMPONENT)
set(ARG_COMPONENT hicn)
endif()
- foreach(library ${TARGET_LIBS})
+ set(BUILD_ROOT ${CMAKE_BINARY_DIR}/build-root)
- if (WIN32)
- target_compile_options(${library} PRIVATE)
- else ()
- target_compile_options(${library} PRIVATE -Wall)
- endif ()
+ foreach(library ${TARGET_LIBS})
if(HICN_VERSION)
set_target_properties(${library}
@@ -98,9 +99,27 @@ macro(build_library lib)
set_target_properties(${library}
PROPERTIES
- OUTPUT_NAME ${lib}
+ INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib"
+ INSTALL_RPATH_USE_LINK_PATH TRUE
+ ARCHIVE_OUTPUT_DIRECTORY "${BUILD_ROOT}/lib"
+ LIBRARY_OUTPUT_DIRECTORY "${BUILD_ROOT}/lib"
+ RUNTIME_OUTPUT_DIRECTORY "${BUILD_ROOT}/bin"
)
+ if (WIN32)
+ target_compile_options(${library} PRIVATE)
+ set_target_properties(${library}
+ PROPERTIES
+ WINDOWS_EXPORT_ALL_SYMBOLS TRUE
+ )
+ else ()
+ target_compile_options(${library} PRIVATE -Wall)
+ set_target_properties(${library}
+ PROPERTIES
+ OUTPUT_NAME ${lib}
+ )
+ endif ()
+
# library deps
if(ARG_LINK_LIBRARIES)
target_link_libraries(${library} ${ARG_LINK_LIBRARIES})
@@ -119,7 +138,9 @@ macro(build_library lib)
install(
TARGETS ${library}
- DESTINATION lib
+ RUNTIME DESTINATION bin
+ ARCHIVE DESTINATION lib
+ LIBRARY DESTINATION lib
COMPONENT ${ARG_COMPONENT}
)