aboutsummaryrefslogtreecommitdiffstats
path: root/cmake/Modules/BuildMacros.cmake
diff options
context:
space:
mode:
Diffstat (limited to 'cmake/Modules/BuildMacros.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}
)