mirror of
https://github.com/crioux/turbo-linecount.git
synced 2024-10-27 17:24:01 +00:00
e79cb700c1
add static linked version of everything
54 lines
1.6 KiB
CMake
54 lines
1.6 KiB
CMake
CMAKE_MINIMUM_REQUIRED(VERSION 3.0.0)
|
|
PROJECT (turbo_linecount)
|
|
|
|
IF(MSVC)
|
|
|
|
OPTION (USE_STATIC_RUNTIME "Use Static Runtime" OFF)
|
|
|
|
SET(CMAKE_CONFIGURATION_TYPES "Debug;Release" CACHE STRING "limited configs" FORCE)
|
|
|
|
SET(CMAKE_CXX_FLAGS_DEBUG "/Od /MDd")
|
|
SET(CMAKE_C_FLAGS_DEBUG "/Od /MDd")
|
|
SET(CMAKE_CXX_FLAGS_RELEASE "/Ox /Ob2 /MD")
|
|
SET(CMAKE_C_FLAGS_RELEASE "/Ox /Ob2 /MD")
|
|
|
|
# Force static runtime libraries
|
|
IF(USE_STATIC_RUNTIME)
|
|
MESSAGE("Using Static Runtime")
|
|
FOREACH(flag
|
|
CMAKE_C_FLAGS_RELEASE CMAKE_C_FLAGS_RELWITHDEBINFO
|
|
CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_DEBUG_INIT
|
|
CMAKE_CXX_FLAGS_RELEASE CMAKE_CXX_FLAGS_RELWITHDEBINFO
|
|
CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_DEBUG_INIT)
|
|
STRING(REPLACE "/MD" "/MT" "${flag}" "${${flag}}")
|
|
ENDFOREACH()
|
|
ENDIF()
|
|
ELSE()
|
|
FIND_PACKAGE (Threads REQUIRED)
|
|
SET(CMAKE_CXX_FLAGS_RELEASE "-O3")
|
|
SET(CMAKE_C_FLAGS_RELEASE "-O3")
|
|
ADD_DEFINITIONS(-D_LARGEFILE_SOURCE=1 -D_LARGEFILE64_SOURCE=1 -D_FILE_OFFSET_BITS=64)
|
|
ENDIF()
|
|
|
|
ADD_LIBRARY (turbo_linecount SHARED src/turbo_linecount.cpp src/turbo_linecount.h)
|
|
ADD_LIBRARY (turbo_linecount_static STATIC src/turbo_linecount.cpp src/turbo_linecount.h)
|
|
ADD_EXECUTABLE (tlc src/main.cpp)
|
|
|
|
|
|
IF(THREADS_HAVE_PTHREAD_ARG)
|
|
SET_PROPERTY(TARGET tlc PROPERTY COMPILE_OPTIONS "-pthread")
|
|
SET_PROPERTY(TARGET tlc PROPERTY INTERFACE_COMPILE_OPTIONS "-pthread")
|
|
ENDIF()
|
|
|
|
TARGET_LINK_LIBRARIES (tlc turbo_linecount_static ${CMAKE_THREAD_LIBS_INIT})
|
|
|
|
INSTALL(TARGETS tlc
|
|
DESTINATION "bin"
|
|
)
|
|
INSTALL(TARGETS turbo_linecount turbo_linecount_static
|
|
DESTINATION "lib"
|
|
)
|
|
INSTALL(FILES src/turbo_linecount.h
|
|
DESTINATION "include"
|
|
)
|