mirror of
https://github.com/VectorCamp/vectorscan.git
synced 2025-06-28 16:41:01 +03:00
cmake: don't build static libs if we don't have to
This commit is contained in:
parent
ce6a10ef58
commit
79308e6791
@ -132,6 +132,12 @@ if (BUILD_STATIC_AND_SHARED OR BUILD_SHARED_LIBS)
|
|||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if (NOT BUILD_SHARED_LIBS)
|
||||||
|
# build static libs
|
||||||
|
set(BUILD_STATIC_LIBS ON)
|
||||||
|
mark_as_advanced(BUILD_STATIC_LIBS)
|
||||||
|
endif ()
|
||||||
|
|
||||||
#for config
|
#for config
|
||||||
if (OPTIMISE)
|
if (OPTIMISE)
|
||||||
set(HS_OPTIMIZE ON)
|
set(HS_OPTIMIZE ON)
|
||||||
@ -1084,19 +1090,27 @@ if (NOT FAT_RUNTIME)
|
|||||||
if (HAVE_AVX2)
|
if (HAVE_AVX2)
|
||||||
set(hs_exec_SRCS ${hs_exec_SRCS} ${hs_exec_avx2_SRCS})
|
set(hs_exec_SRCS ${hs_exec_SRCS} ${hs_exec_avx2_SRCS})
|
||||||
endif()
|
endif()
|
||||||
|
if (BUILD_STATIC_LIBS)
|
||||||
add_library(hs_exec OBJECT ${hs_exec_SRCS})
|
add_library(hs_exec OBJECT ${hs_exec_SRCS})
|
||||||
|
|
||||||
add_library(hs_runtime STATIC src/hs_version.c src/hs_valid_platform.c $<TARGET_OBJECTS:hs_exec>)
|
add_library(hs_runtime STATIC src/hs_version.c src/hs_valid_platform.c $<TARGET_OBJECTS:hs_exec>)
|
||||||
set_target_properties(hs_runtime PROPERTIES LINKER_LANGUAGE C)
|
set_target_properties(hs_runtime PROPERTIES LINKER_LANGUAGE C)
|
||||||
|
|
||||||
|
add_library(hs STATIC ${hs_SRCS} src/hs_valid_platform.c $<TARGET_OBJECTS:hs_exec>)
|
||||||
|
endif (BUILD_STATIC_LIBS)
|
||||||
|
|
||||||
if (BUILD_STATIC_AND_SHARED OR BUILD_SHARED_LIBS)
|
if (BUILD_STATIC_AND_SHARED OR BUILD_SHARED_LIBS)
|
||||||
add_library(hs_exec_shared OBJECT ${hs_exec_SRCS})
|
add_library(hs_exec_shared OBJECT ${hs_exec_SRCS})
|
||||||
set_target_properties(hs_exec_shared PROPERTIES POSITION_INDEPENDENT_CODE TRUE)
|
set_target_properties(hs_exec_shared PROPERTIES POSITION_INDEPENDENT_CODE TRUE)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
else (FAT_RUNTIME)
|
else (FAT_RUNTIME)
|
||||||
|
|
||||||
set(BUILD_WRAPPER "${PROJECT_SOURCE_DIR}/cmake/build_wrapper.sh")
|
set(BUILD_WRAPPER "${PROJECT_SOURCE_DIR}/cmake/build_wrapper.sh")
|
||||||
|
set_source_files_properties(src/dispatcher.c PROPERTIES
|
||||||
|
COMPILE_FLAGS "-Wno-unused-parameter -Wno-unused-function")
|
||||||
|
|
||||||
|
if (BUILD_STATIC_LIBS)
|
||||||
add_library(hs_exec_core2 OBJECT ${hs_exec_SRCS})
|
add_library(hs_exec_core2 OBJECT ${hs_exec_SRCS})
|
||||||
set_target_properties(hs_exec_core2 PROPERTIES
|
set_target_properties(hs_exec_core2 PROPERTIES
|
||||||
COMPILE_FLAGS "-march=core2"
|
COMPILE_FLAGS "-march=core2"
|
||||||
@ -1119,10 +1133,24 @@ else (FAT_RUNTIME)
|
|||||||
${hs_exec_common_SRCS}
|
${hs_exec_common_SRCS}
|
||||||
src/dispatcher.c
|
src/dispatcher.c
|
||||||
)
|
)
|
||||||
set_source_files_properties(src/dispatcher.c PROPERTIES
|
|
||||||
COMPILE_FLAGS "-Wno-unused-parameter -Wno-unused-function")
|
# hs_version.c is added explicitly to avoid some build systems that refuse to
|
||||||
|
# create a lib without any src (I'm looking at you Xcode)
|
||||||
|
|
||||||
|
add_library(hs_runtime STATIC src/hs_version.c
|
||||||
|
$<TARGET_OBJECTS:hs_exec_common> $<TARGET_OBJECTS:hs_exec_core2>
|
||||||
|
$<TARGET_OBJECTS:hs_exec_corei7> $<TARGET_OBJECTS:hs_exec_avx2>)
|
||||||
|
set_target_properties(hs_runtime PROPERTIES LINKER_LANGUAGE C)
|
||||||
|
|
||||||
|
# we want the static lib for testing
|
||||||
|
add_library(hs STATIC src/hs_version.c src/hs_valid_platform.c
|
||||||
|
${hs_SRCS} $<TARGET_OBJECTS:hs_exec_common> $<TARGET_OBJECTS:hs_exec_core2>
|
||||||
|
$<TARGET_OBJECTS:hs_exec_corei7> $<TARGET_OBJECTS:hs_exec_avx2>)
|
||||||
|
|
||||||
|
endif (BUILD_STATIC_LIBS)
|
||||||
|
|
||||||
if (BUILD_STATIC_AND_SHARED OR BUILD_SHARED_LIBS)
|
if (BUILD_STATIC_AND_SHARED OR BUILD_SHARED_LIBS)
|
||||||
|
# build shared libs
|
||||||
add_library(hs_exec_shared_core2 OBJECT ${hs_exec_SRCS})
|
add_library(hs_exec_shared_core2 OBJECT ${hs_exec_SRCS})
|
||||||
set_target_properties(hs_exec_shared_core2 PROPERTIES
|
set_target_properties(hs_exec_shared_core2 PROPERTIES
|
||||||
COMPILE_FLAGS "-march=core2"
|
COMPILE_FLAGS "-march=core2"
|
||||||
@ -1151,16 +1179,8 @@ else (FAT_RUNTIME)
|
|||||||
endif() # SHARED
|
endif() # SHARED
|
||||||
|
|
||||||
|
|
||||||
# hs_version.c is added explicitly to avoid some build systems that refuse to
|
|
||||||
# create a lib without any src (I'm looking at you Xcode)
|
|
||||||
|
|
||||||
add_library(hs_runtime STATIC src/hs_version.c
|
|
||||||
$<TARGET_OBJECTS:hs_exec_common> $<TARGET_OBJECTS:hs_exec_core2>
|
|
||||||
$<TARGET_OBJECTS:hs_exec_corei7> $<TARGET_OBJECTS:hs_exec_avx2>)
|
|
||||||
endif (NOT FAT_RUNTIME)
|
endif (NOT FAT_RUNTIME)
|
||||||
|
|
||||||
|
|
||||||
set_target_properties(hs_runtime PROPERTIES LINKER_LANGUAGE C)
|
|
||||||
if (NOT BUILD_SHARED_LIBS)
|
if (NOT BUILD_SHARED_LIBS)
|
||||||
install(TARGETS hs_runtime DESTINATION lib)
|
install(TARGETS hs_runtime DESTINATION lib)
|
||||||
endif()
|
endif()
|
||||||
@ -1189,16 +1209,9 @@ $<TARGET_OBJECTS:hs_exec_shared>)
|
|||||||
LIBRARY DESTINATION lib)
|
LIBRARY DESTINATION lib)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (NOT FAT_RUNTIME)
|
if (BUILD_STATIC_LIBS)
|
||||||
add_library(hs STATIC ${hs_SRCS} src/hs_valid_platform.c $<TARGET_OBJECTS:hs_exec>)
|
add_dependencies(hs ragel_Parser)
|
||||||
else()
|
endif ()
|
||||||
# we want the static lib for testing
|
|
||||||
add_library(hs STATIC src/hs_version.c src/hs_valid_platform.c
|
|
||||||
${hs_SRCS} $<TARGET_OBJECTS:hs_exec_common> $<TARGET_OBJECTS:hs_exec_core2>
|
|
||||||
$<TARGET_OBJECTS:hs_exec_corei7> $<TARGET_OBJECTS:hs_exec_avx2>)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
add_dependencies(hs ragel_Parser)
|
|
||||||
|
|
||||||
if (NOT BUILD_SHARED_LIBS)
|
if (NOT BUILD_SHARED_LIBS)
|
||||||
install(TARGETS hs DESTINATION lib)
|
install(TARGETS hs DESTINATION lib)
|
||||||
@ -1228,6 +1241,13 @@ install(TARGETS hs_shared
|
|||||||
LIBRARY DESTINATION lib)
|
LIBRARY DESTINATION lib)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
# used by tools and other targets
|
||||||
|
if (NOT BUILD_STATIC_LIBS)
|
||||||
|
# use shared lib without having to change all the targets
|
||||||
|
add_library(hs ALIAS hs_shared)
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
|
||||||
if(NOT WIN32)
|
if(NOT WIN32)
|
||||||
add_subdirectory(examples)
|
add_subdirectory(examples)
|
||||||
endif()
|
endif()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user