Commit eb3c4403 authored by Vladislav Vaintroub's avatar Vladislav Vaintroub

Replace ADD_EXECUTABLE with MYSQL_ADD_EXECUTABLE for binaries that are installed.

MYSQL_ADD_EXECUTABLE  will instructs CPack where to install the exe. On Windows, it also 
adds version resource and   if -DSIGNCODE  was given, will sign the exe in packaging step.
parent 07bfd261
......@@ -19,6 +19,7 @@ if("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" GREATER 2.6)
CMAKE_POLICY(VERSION 2.8)
endif()
SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake)
# First, decide about build type (debug or release)
# If custom compiler flags are set or cmake is invoked with -DCMAKE_BUILD_TYPE,
......@@ -70,6 +71,7 @@ INCLUDE(cmake/libutils.cmake)
INCLUDE(cmake/dtrace.cmake)
INCLUDE(cmake/plugin.cmake)
INCLUDE(cmake/install_macros.cmake)
INCLUDE(mysql_add_executable)
# Handle options
OPTION(DISABLE_SHARED
......
......@@ -27,40 +27,40 @@ INCLUDE_DIRECTORIES(
ADD_DEFINITIONS(${READLINE_DEFINES})
ADD_DEFINITIONS(${SSL_DEFINES})
ADD_EXECUTABLE(mysql completion_hash.cc mysql.cc readline.cc sql_string.cc)
MYSQL_ADD_EXECUTABLE(mysql completion_hash.cc mysql.cc readline.cc sql_string.cc)
TARGET_LINK_LIBRARIES(mysql mysqlclient)
IF(UNIX)
TARGET_LINK_LIBRARIES(mysql ${READLINE_LIBRARY})
ENDIF(UNIX)
ADD_EXECUTABLE(mysqltest mysqltest.cc)
MYSQL_ADD_EXECUTABLE(mysqltest mysqltest.cc)
SET_SOURCE_FILES_PROPERTIES(mysqltest.cc PROPERTIES COMPILE_FLAGS "-DTHREADS")
TARGET_LINK_LIBRARIES(mysqltest mysqlclient regex)
ADD_EXECUTABLE(mysqlcheck mysqlcheck.c)
MYSQL_ADD_EXECUTABLE(mysqlcheck mysqlcheck.c)
TARGET_LINK_LIBRARIES(mysqlcheck mysqlclient)
ADD_EXECUTABLE(mysqldump mysqldump.c ../sql-common/my_user.c)
MYSQL_ADD_EXECUTABLE(mysqldump mysqldump.c ../sql-common/my_user.c)
TARGET_LINK_LIBRARIES(mysqldump mysqlclient)
ADD_EXECUTABLE(mysqlimport mysqlimport.c)
MYSQL_ADD_EXECUTABLE(mysqlimport mysqlimport.c)
TARGET_LINK_LIBRARIES(mysqlimport mysqlclient)
ADD_EXECUTABLE(mysql_upgrade mysql_upgrade.c)
MYSQL_ADD_EXECUTABLE(mysql_upgrade mysql_upgrade.c)
TARGET_LINK_LIBRARIES(mysql_upgrade mysqlclient)
ADD_DEPENDENCIES(mysql_upgrade GenFixPrivs)
ADD_EXECUTABLE(mysqlshow mysqlshow.c)
MYSQL_ADD_EXECUTABLE(mysqlshow mysqlshow.c)
TARGET_LINK_LIBRARIES(mysqlshow mysqlclient)
ADD_EXECUTABLE(mysqlbinlog mysqlbinlog.cc)
MYSQL_ADD_EXECUTABLE(mysqlbinlog mysqlbinlog.cc)
TARGET_LINK_LIBRARIES(mysqlbinlog mysqlclient)
ADD_EXECUTABLE(mysqladmin mysqladmin.cc)
MYSQL_ADD_EXECUTABLE(mysqladmin mysqladmin.cc)
TARGET_LINK_LIBRARIES(mysqladmin mysqlclient)
ADD_EXECUTABLE(mysqlslap mysqlslap.c)
MYSQL_ADD_EXECUTABLE(mysqlslap mysqlslap.c)
SET_SOURCE_FILES_PROPERTIES(mysqlslap.c PROPERTIES COMPILE_FLAGS "-DTHREADS")
TARGET_LINK_LIBRARIES(mysqlslap mysqlclient)
......@@ -69,17 +69,3 @@ ADD_EXECUTABLE(echo echo.c)
SET_TARGET_PROPERTIES (mysqlcheck mysqldump mysqlimport mysql_upgrade mysqlshow mysqlslap
PROPERTIES HAS_CXX TRUE)
SET(INSTALL_EXES
mysqlcheck
mysqldump
mysqlimport
mysql_upgrade
mysqlshow
mysqlslap
mysql
mysqladmin
mysqlbinlog
mysqltest)
MYSQL_INSTALL_TARGETS(${INSTALL_EXES} DESTINATION bin)
......@@ -205,7 +205,7 @@ ENDMACRO()
# Create libs from libs.
# Merges static libraries, creates shared libraries out of convenience libraries.
# MYSQL_MERGE_LIBRARIES(target [STATIC|SHARED|MODULE]
# MERGE_LIBRARIES(target [STATIC|SHARED|MODULE]
# [linklib1 .... linklibN]
# [EXPORTS exported_func1 .... exportedFuncN]
# [OUTPUT_NAME output_name]
......@@ -213,7 +213,7 @@ ENDMACRO()
MACRO(MERGE_LIBRARIES)
CMAKE_PARSE_ARGUMENTS(ARG
"EXPORTS;OUTPUT_NAME"
"STATIC;SHARED;MODULE"
"STATIC;SHARED;MODULE;NOINSTALL"
${ARGN}
)
LIST(GET ARG_DEFAULT_ARGS 0 TARGET)
......@@ -247,10 +247,11 @@ MACRO(MERGE_LIBRARIES)
ENDIF()
ENDFOREACH()
ENDIF()
CREATE_EXPORT_FILE(SRC ${TARGET} "${ARG_EXPORTS}")
ADD_LIBRARY(${TARGET} SHARED ${SRC})
IF(WIN32 AND NOT ARG_NOINSTALL)
ADD_VERSION_INFO(${TARGET} VFT_DLL SRC )
ENDIF()
ADD_LIBRARY(${TARGET} ${LIBTYPE} ${SRC})
TARGET_LINK_LIBRARIES(${TARGET} ${LIBS})
IF(ARG_OUTPUT_NAME)
SET_TARGET_PROPERTIES(${TARGET} PROPERTIES OUTPUT_NAME "${ARG_OUTPUT_NAME}")
......@@ -258,6 +259,9 @@ MACRO(MERGE_LIBRARIES)
ELSE()
MESSAGE(FATAL_ERROR "Unknown library type")
ENDIF()
IF(NOT ARG_NOINSTALL)
MYSQL_INSTALL_TARGETS(${TARGET} DESTINATION lib)
ENDIF()
ENDMACRO()
FUNCTION(GET_DEPENDEND_OS_LIBS target result)
......@@ -279,11 +283,11 @@ ENDFUNCTION()
MACRO(RESTRICT_SYMBOL_EXPORTS target)
IF(CMAKE_COMPILER_IS_GNUCXX AND UNIX)
GET_TARGET_PROPERTY(COMPILE_FLAGS ${target} COMPILE_FLAGS)
IF(NOT COMPILE_FLAGS)
# Avoid COMPILE_FLAGS-NOTFOUND
SET(COMPILE_FLAGS)
ENDIF()
IF(NOT COMPILE_FLAGS)
# Avoid COMPILE_FLAGS-NOTFOUND
SET(COMPILE_FLAGS)
ENDIF()
SET_TARGET_PROPERTIES(${target} PROPERTIES
COMPILE_FLAGS "${COMPILE_FLAGS} -fvisibility=hidden")
COMPILE_FLAGS "${COMPILE_FLAGS} -fvisibility=hidden")
ENDIF()
ENDMACRO()
......@@ -55,9 +55,10 @@ MACRO(GET_MYSQL_VERSION)
SET(VERSION ${VERSION_STRING})
STRING(REGEX REPLACE "([0-9]+)\\.[0-9]+\\.[0-9]+[^ ]+" "\\1" MAJOR_VERSION "${VERSION_STRING}")
STRING(REGEX REPLACE "[0-9]+\\.([0-9]+)\\.[0-9]+[^ ]+" "\\1" MINOR_VERSION "${VERSION_STRING}")
STRING(REGEX REPLACE "[0-9]+\\.[0-9]+\\.([0-9]+)[^ ]+" "\\1" PATCH "${VERSION_STRING}")
STRING(REGEX REPLACE "([0-9]+)\\.[0-9]+\\.[0-9]+" "\\1" MAJOR_VERSION "${VERSION_STRING}")
STRING(REGEX REPLACE "[0-9]+\\.([0-9]+)\\.[0-9]+" "\\1" MINOR_VERSION "${VERSION_STRING}")
STRING(REGEX REPLACE "[0-9]+\\.[0-9]+\\.([0-9]+)" "\\1" PATCH "${VERSION_STRING}")
SET(MYSQL_BASE_VERSION "${MAJOR_VERSION}.${MINOR_VERSION}" CACHE INTERNAL "MySQL Base version")
SET(MYSQL_NO_DASH_VERSION "${MAJOR_VERSION}.${MINOR_VERSION}.${PATCH}")
MATH(EXPR MYSQL_VERSION_ID "10000*${MAJOR_VERSION} + 100*${MINOR_VERSION} + ${PATCH}")
......@@ -150,39 +151,4 @@ SET(CPACK_SOURCE_IGNORE_FILES
SET(PRODUCTNAME "MySQL Server")
SET(COMPANYNAME ${CPACK_PACKAGE_VENDOR})
# Function to embed version info into executables/dlls on Windows
# Refer http://msdn.microsoft.com/en-us/library/aa381058(VS.85).aspx
# for more information
FUNCTION(WIN32_ADD_VERSION_INFO SOURCES)
IF(NOT WIN32)
RETURN()
ENDIF()
IF(NOT CMAKE_RC_COMPILER)
RETURN()
ENDIF()
IF(NOT FILETYPE)
SET(FILETYPE VFT_APP)
ENDIF()
IF(NOT MAJOR_VERSION)
MESSAGE(FATAL_ERROR "MAJOR_VERSION is not defined")
ENDIF()
IF(NOT MINOR_VERSION)
MESSAGE(FATAL_ERROR "MINOR_VERSION is not defined")
ENDIF()
IF(NOT PATCH)
SET(PATCH 0)
ENDIF()
GET_TARGET_PROPERTY(target_location ${target} LOCATION)
GET_FILENAME_COMPONENT(INTERNALNAME ${target_location} NAME_WE)
IF(NOT FILEDESCRIPTION)
SET(FILEDESCRIPTION ${INTERNALNAME})
ENDIF()
GET_FILENAME_COMPONENT(ORIGINALFILENAME ${target_location} NAME)
CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/cmake/versioninfo.rc.in
${CMAKE_CURRENT_BINARY_DIR}/${target}_versioninfo.rc)
LIST(APPEND ${SOURCES} ${CMAKE_CURRENT_BINARY_DIR}/${target}_versioninfo.rc)
ENDFUNCTION()
......@@ -120,7 +120,16 @@ MACRO(MYSQL_ADD_PLUGIN)
FORCE)
ENDIF()
ELSEIF(NOT WITHOUT_${plugin} AND NOT ARG_STATIC_ONLY AND NOT WITHOUT_DYNAMIC_PLUGINS)
IF(NOT ARG_MODULE_OUTPUT_NAME)
IF(ARG_STORAGE_ENGINE)
SET(ARG_MODULE_OUTPUT_NAME "ha_${target}")
ELSE()
SET(ARG_MODULE_OUTPUT_NAME "${target}")
ENDIF()
ENDIF()
IF(WIN32)
ADD_VERSION_INFO(${ARG_MODULE_OUTPUT_NAME} VFT_DLL SOURCES)
ENDIF()
ADD_LIBRARY(${target} MODULE ${SOURCES})
DTRACE_INSTRUMENT(${target})
SET_TARGET_PROPERTIES (${target} PROPERTIES PREFIX ""
......@@ -142,13 +151,7 @@ MACRO(MYSQL_ADD_PLUGIN)
ENDIF()
ADD_DEPENDENCIES(${target} GenError ${ARG_DEPENDENCIES})
IF(NOT ARG_MODULE_OUTPUT_NAME)
IF(ARG_STORAGE_ENGINE)
SET(ARG_MODULE_OUTPUT_NAME "ha_${target}")
ELSE()
SET(ARG_MODULE_OUTPUT_NAME "${target}")
ENDIF()
ENDIF()
SET_TARGET_PROPERTIES(${target} PROPERTIES
OUTPUT_NAME "${ARG_MODULE_OUTPUT_NAME}")
# Install dynamic library
......
......@@ -13,7 +13,7 @@ BEGIN
BLOCK "040904E4"
BEGIN
VALUE "FileDescription", "@FILEDESCRIPTION@\0"
VALUE "FileVersion", "@MAJOR_VERSION@.@MINOR_VERSION@.@PATCH@\0"
VALUE "FileVersion", "@MAJOR_VERSION@.@MINOR_VERSION@.@PATCH@.0\0"
VALUE "InternalName", "@INTERNALNAME@\0"
VALUE "OriginalFilename", "@ORIGINALFILENAME@\0"
END
......
......@@ -49,14 +49,14 @@ ADD_CUSTOM_TARGET(GenError
${PROJECT_BINARY_DIR}/sql/share/english/errmsg.sys
${PROJECT_SOURCE_DIR}/sql/share/errmsg-utf8.txt)
ADD_EXECUTABLE(my_print_defaults my_print_defaults.c)
MYSQL_ADD_EXECUTABLE(my_print_defaults my_print_defaults.c)
TARGET_LINK_LIBRARIES(my_print_defaults mysys)
ADD_EXECUTABLE(perror perror.c)
MYSQL_ADD_EXECUTABLE(perror perror.c)
ADD_DEPENDENCIES(perror GenError)
TARGET_LINK_LIBRARIES(perror mysys)
ADD_EXECUTABLE(resolveip resolveip.c)
MYSQL_ADD_EXECUTABLE(resolveip resolveip.c)
TARGET_LINK_LIBRARIES(resolveip mysys)
IF(CMAKE_SYSTEM_NAME STREQUAL "SunOS")
INCLUDE(CheckFunctionExists)
......@@ -69,15 +69,12 @@ ENDIF()
ADD_EXECUTABLE(replace replace.c)
TARGET_LINK_LIBRARIES(replace mysys)
IF(UNIX)
ADD_EXECUTABLE(innochecksum innochecksum.c)
ADD_EXECUTABLE(resolve_stack_dump resolve_stack_dump.c)
MYSQL_ADD_EXECUTABLE(innochecksum innochecksum.c)
MYSQL_ADD_EXECUTABLE(resolve_stack_dump resolve_stack_dump.c)
TARGET_LINK_LIBRARIES(resolve_stack_dump mysys)
ADD_EXECUTABLE(mysql_waitpid mysql_waitpid.c)
MYSQL_ADD_EXECUTABLE(mysql_waitpid mysql_waitpid.c)
TARGET_LINK_LIBRARIES(mysql_waitpid mysys)
MYSQL_INSTALL_TARGETS(innochecksum mysql_waitpid resolve_stack_dump DESTINATION bin)
ENDIF()
MYSQL_INSTALL_TARGETS(perror resolveip my_print_defaults DESTINATION bin)
......@@ -152,14 +152,12 @@ SET(LIBS clientlib dbug strings vio mysys ${ZLIB_LIBRARY} ${SSL_LIBRARIES})
# Merge several convenience libraries into one big mysqlclient
# and link them together into shared library.
MERGE_LIBRARIES(mysqlclient STATIC ${LIBS})
MYSQL_INSTALL_TARGETS(mysqlclient DESTINATION lib)
IF(UNIX)
INSTALL_SYMLINK(${CMAKE_STATIC_LIBRARY_PREFIX}mysqlclient_r mysqlclient lib)
ENDIF()
IF(NOT DISABLE_SHARED)
MERGE_LIBRARIES(libmysql SHARED ${LIBS} EXPORTS ${CLIENT_API_FUNCTIONS})
MYSQL_INSTALL_TARGETS(libmysql DESTINATION lib)
IF(UNIX)
# Name of shared library is mysqlclient on Unix
SET_TARGET_PROPERTIES(libmysql PROPERTIES
......
......@@ -120,9 +120,7 @@ ENDFOREACH()
MERGE_LIBRARIES(mysqlserver STATIC ${EMBEDDED_LIBS}
OUTPUT_NAME ${MYSQLSERVER_OUTPUT_NAME})
MYSQL_INSTALL_TARGETS(mysqlserver DESTINATION lib)
IF(MSVC AND NOT DISABLE_SHARED)
MERGE_LIBRARIES(libmysqld SHARED ${LIBS} EXPORTS ${CLIENT_API_FUNCTIONS})
MYSQL_INSTALL_TARGETS(libmysqld DESTINATION lib)
ENDIF()
......@@ -95,12 +95,11 @@ TARGET_LINK_LIBRARIES(sql ${MYSQLD_STATIC_PLUGIN_LIBS}
IF(WIN32)
SET(MYSQLD_SOURCE main.cc nt_servc.cc nt_servc.h)
WIN32_ADD_VERSION_INFO(MYSQLD_SOURCE)
ELSE()
SET(MYSQLD_SOURCE main.cc ${DTRACE_PROBES_ALL})
ENDIF()
ADD_EXECUTABLE(mysqld ${MYSQLD_SOURCE})
MYSQL_ADD_EXECUTABLE(mysqld ${MYSQLD_SOURCE})
IF(NOT WITHOUT_DYNAMIC_PLUGINS)
SET_TARGET_PROPERTIES(mysqld PROPERTIES ENABLE_EXPORTS TRUE)
......@@ -127,7 +126,6 @@ IF(NOT WITHOUT_DYNAMIC_PLUGINS)
ENDIF()
SET_TARGET_PROPERTIES(mysqld PROPERTIES ENABLE_EXPORTS TRUE)
SET_TARGET_PROPERTIES(mysqld PROPERTIES OUTPUT_NAME mysqld${MYSQLD_EXE_SUFFIX})
TARGET_LINK_LIBRARIES(mysqld sql)
# Provide plugins with minimal set of libraries
SET(INTERFACE_LIBS ${LIBRT})
......@@ -140,8 +138,6 @@ ENDIF()
# from static libraries
DTRACE_INSTRUMENT_STATIC_LIBS(mysqld
"sql;mysys;${MYSQLD_STATIC_PLUGIN_LIBS}")
MYSQL_INSTALL_TARGETS(mysqld DESTINATION bin)
# Handle out-of-source build from source package with possibly broken
......
......@@ -31,38 +31,37 @@ MYSQL_ADD_PLUGIN(myisam ${MYISAM_SOURCES}
MANDATORY
RECOMPILE_FOR_EMBEDDED)
ADD_EXECUTABLE(myisam_ftdump myisam_ftdump.c)
TARGET_LINK_LIBRARIES(myisam_ftdump myisam mysys)
TARGET_LINK_LIBRARIES(myisam mysys)
ADD_EXECUTABLE(myisamchk myisamchk.c)
TARGET_LINK_LIBRARIES(myisamchk myisam mysys)
MYSQL_ADD_EXECUTABLE(myisam_ftdump myisam_ftdump.c)
TARGET_LINK_LIBRARIES(myisam_ftdump myisam)
ADD_EXECUTABLE(myisamlog myisamlog.c)
TARGET_LINK_LIBRARIES(myisamlog myisam mysys)
MYSQL_ADD_EXECUTABLE(myisamchk myisamchk.c)
TARGET_LINK_LIBRARIES(myisamchk myisam)
ADD_EXECUTABLE(myisampack myisampack.c)
MYSQL_ADD_EXECUTABLE(myisamlog myisamlog.c)
TARGET_LINK_LIBRARIES(myisamlog myisam)
TARGET_LINK_LIBRARIES(myisampack myisam mysys)
MYSQL_ADD_EXECUTABLE(myisampack myisampack.c)
TARGET_LINK_LIBRARIES(myisampack myisam)
IF(WITH_UNIT_TESTS AND FALSE)
ADD_EXECUTABLE(mi_test1 mi_test1.c)
TARGET_LINK_LIBRARIES(mi_test1 myisam mysys)
TARGET_LINK_LIBRARIES(mi_test1 myisam)
ADD_EXECUTABLE(mi_test2 mi_test2.c)
TARGET_LINK_LIBRARIES(mi_test2 myisam mysys)
TARGET_LINK_LIBRARIES(mi_test2 myisam)
ADD_EXECUTABLE(mi_test3 mi_test3.c)
TARGET_LINK_LIBRARIES(mi_test3 myisam mysys)
TARGET_LINK_LIBRARIES(mi_test3 myisam)
ADD_EXECUTABLE(sp_test sp_test.c)
TARGET_LINK_LIBRARIES(sp_test myisam mysys)
TARGET_LINK_LIBRARIES(sp_test myisam)
ADD_EXECUTABLE(rt_test rt_test.c)
TARGET_LINK_LIBRARIES(rt_test myisam mysys)
TARGET_LINK_LIBRARIES(rt_test myisam)
ENDIF()
IF (MSVC)
SET_TARGET_PROPERTIES(myisamchk myisampack PROPERTIES LINK_FLAGS "setargv.obj")
ENDIF()
MYSQL_INSTALL_TARGETS(myisamchk myisamlog myisampack myisam_ftdump DESTINATION bin)
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