Combine Vala{Lib,Plugin}CommonRules.

This commit is contained in:
Kolan Sh 2016-04-01 18:01:50 +03:00
parent c16c3e5d81
commit e94a91ba7e
2 changed files with 34 additions and 41 deletions

View File

@ -3,16 +3,17 @@ INCLUDE (UseVala)
INCLUDE (CFlagsCommonRules)
FIND_PACKAGE (PkgConfig REQUIRED)
IF (WIN32)
SET (CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/run") # Avoid of "dll not found" messages
ENDIF (WIN32)
IF (NOT LibNoApi)
SET (export_vaapi "--vapi=${LibName}-${MAJOR}.vapi")
SET (generate_header ${LibName}-${MAJOR})
ENDIF (NOT LibNoApi)
VALA_PRECOMPILE (VALA_C ${LibSources}
PACKAGES ${LibPackages}
OPTIONS --thread ${LibValaOpts} ${VALA_DEBUG} --vapi=${LibName}-${MAJOR}.vapi
OPTIONS --thread ${LibValaOpts} ${VALA_DEBUG} ${export_vaapi}
CUSTOM_VAPIS ${LibCustomVapis}
GENERATE_VAPI
GENERATE_HEADER ${LibName}-${MAJOR}
GENERATE_HEADER ${generate_header}
)
PKG_CHECK_MODULES (PKGS REQUIRED ${LibPkgModules})
INCLUDE_DIRECTORIES (${PKGS_INCLUDE_DIRS} ${CMAKE_BINARY_DIR}/po)
@ -21,23 +22,40 @@ ADD_DEFINITIONS (-DGETTEXT_PACKAGE="${PROJECT_LOWERCASE_NAME}-${MAJOR}")
TARGET_LINK_LIBRARIES (${LibName} ${PKGS_LIBRARIES} ${LibLinkLibs})
SET_TARGET_PROPERTIES (${LibName} PROPERTIES VERSION ${MAJOR}.${MINOR}.${PATCH})
SET_TARGET_PROPERTIES (${LibName} PROPERTIES SOVERSION ${MAJOR})
IF (WIN32)
IF (NOT LibIsPlugin)
SET (CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/run") # Avoid of "dll not found" messages
ENDIF (NOT LibIsPlugin)
SET_TARGET_PROPERTIES (${LibName} PROPERTIES PREFIX "" IMPORT_PREFIX ""
SUFFIX "-${MAJOR}.dll" IMPORT_SUFFIX "-${MAJOR}.dll.a")
ENDIF (WIN32)
IF (LibInstall)
SET (install_prefix "")
IF (LibIsPlugin)
SET (install_prefix "/${LibInstallPrefix}/${LibName}-${MAJOR}")
ENDIF (LibIsPlugin)
IF (UNIX)
INSTALL (TARGETS ${LibName} DESTINATION lib)
SET (install_dest lib${install_prefix})
ELSEIF (WIN32)
INSTALL (TARGETS ${LibName}
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib)
SET (install_dest bin${install_prefix})
ENDIF (UNIX)
IF (LibInstall)
IF (LibNoApi)
INSTALL (TARGETS ${LibName} RUNTIME DESTINATION ${install_dest}
LIBRARY DESTINATION ${install_dest})
ELSE (LibNoApi)
INSTALL (TARGETS ${LibName} RUNTIME DESTINATION ${install_dest}
LIBRARY DESTINATION ${install_dest}
ARCHIVE DESTINATION lib)
INSTALL (FILES ${CMAKE_CURRENT_BINARY_DIR}/${LibName}-${MAJOR}.h DESTINATION include)
INSTALL (FILES ${CMAKE_CURRENT_BINARY_DIR}/${LibName}-${MAJOR}.vapi DESTINATION share/vala/vapi)
ENDIF (LibNoApi)
ENDIF (LibInstall)
# Access to 'share' directory when debugging (Gettext, Glade, GSchema files, etc...)
IF (NOT LibIsPlugin)
EXECUTE_PROCESS (COMMAND ln -sf ${CMAKE_BINARY_DIR}/share -t ${CMAKE_CURRENT_BINARY_DIR}/..)
ENDIF (NOT LibIsPlugin)

View File

@ -1,25 +0,0 @@
INCLUDE (FindVala)
INCLUDE (UseVala)
INCLUDE (CFlagsCommonRules)
FIND_PACKAGE (PkgConfig REQUIRED)
VALA_PRECOMPILE (VALA_C ${PluginSources}
PACKAGES ${PluginPackages}
OPTIONS --thread ${PluginValaOpts} ${VALA_DEBUG}
CUSTOM_VAPIS ${PluginCustomVapis}
GENERATE_VAPI
GENERATE_HEADER
)
PKG_CHECK_MODULES (PKGS REQUIRED ${PluginPkgModules})
INCLUDE_DIRECTORIES (${PKGS_INCLUDE_DIRS} ${CMAKE_BINARY_DIR}/po)
ADD_LIBRARY (${PluginName} SHARED ${VALA_C} ${PluginExtraSources})
ADD_DEFINITIONS (-DGETTEXT_PACKAGE="${PROJECT_LOWERCASE_NAME}-${MAJOR}")
TARGET_LINK_LIBRARIES (${PluginName} ${PKGS_LIBRARIES} ${PluginLinkLibs})
IF (PluginInstall)
IF (UNIX)
INSTALL (TARGETS ${PluginName} DESTINATION lib/${PluginInstallPrefix}/${PluginName})
ELSEIF (WIN32)
INSTALL (TARGETS ${PluginName} DESTINATION bin/${PluginInstallPrefix}/${PluginName})
ENDIF (UNIX)
ENDIF (PluginInstall)