CMake cleanup

This commit is contained in:
Zeex 2015-04-07 19:24:32 +06:00
parent 05fb325dd1
commit 13f98d5934
2 changed files with 89 additions and 29 deletions

View File

@ -44,10 +44,13 @@ if(WIN32)
set(ARGS_SRCS ${ARGS_SRCS} dllmain.c amxargs.rc)
if(BORLAND)
# Borland linker uses a DEF file if one is in the output directory
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/amxargs.def ${CMAKE_BINARY_DIR}/amxargs.def COPYONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/amxargs.def
${CMAKE_BINARY_DIR}/amxargs.def
COPYONLY)
else()
# For Microsoft Visual C/C++ we can set explicit flags for exports
set_target_properties(amxArgs PROPERTIES LINK_FLAGS "/export:amx_ArgsInit /export:amx_ArgsCleanup /export:amx_ArgsSetCmdLine")
set_target_properties(amxArgs PROPERTIES LINK_FLAGS
"/export:amx_ArgsInit /export:amx_ArgsCleanup /export:amx_ArgsSetCmdLine")
endif()
endif()
@ -58,9 +61,12 @@ set_target_properties(amxDGram PROPERTIES PREFIX "")
if(WIN32)
set(DGRAM_SRCS ${DGRAM_SRCS} dllmain.c amxargs.rc)
if(BORLAND)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/amxdgram.def ${CMAKE_BINARY_DIR}/amxdgram.def COPYONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/amxdgram.def
${CMAKE_BINARY_DIR}/amxdgram.def
COPYONLY)
else()
set_target_properties(amxDGram PROPERTIES LINK_FLAGS "/export:amx_DGramInit /export:amx_DGramCleanup")
set_target_properties(amxDGram PROPERTIES LINK_FLAGS
"/export:amx_DGramInit /export:amx_DGramCleanup")
endif()
endif()
@ -71,9 +77,12 @@ set_target_properties(amxFile PROPERTIES PREFIX "")
if(WIN32)
set(FILE_SRCS ${FILE_SRCS} dllmain.c amxfile.rc)
if(BORLAND)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/amxfile.def ${CMAKE_BINARY_DIR}/amxfile.def COPYONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/amxfile.def
${CMAKE_BINARY_DIR}/amxfile.def
COPYONLY)
else()
set_target_properties(amxFile PROPERTIES LINK_FLAGS "/export:amx_FileInit /export:amx_FileCleanup")
set_target_properties(amxFile PROPERTIES LINK_FLAGS
"/export:amx_FileInit /export:amx_FileCleanup")
endif()
endif()
@ -84,9 +93,12 @@ set_target_properties(amxFixed PROPERTIES PREFIX "")
if(WIN32)
set(FIXED_SRCS ${FIXED_SRCS} dllmain.c amxfixed.rc)
if(BORLAND)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/amxfixed.def ${CMAKE_BINARY_DIR}/amxfixed.def COPYONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/amxfixed.def
${CMAKE_BINARY_DIR}/amxfixed.def
COPYONLY)
else()
set_target_properties(amxFixed PROPERTIES LINK_FLAGS "/export:amx_FixedInit /export:amx_FixedCleanup")
set_target_properties(amxFixed PROPERTIES LINK_FLAGS
"/export:amx_FixedInit /export:amx_FixedCleanup")
endif()
endif()
if(UNIX)
@ -100,9 +112,12 @@ set_target_properties(amxFloat PROPERTIES PREFIX "")
if(WIN32)
set(FLOAT_SRCS ${FLOAT_SRCS} dllmain.c amxfloat.rc)
if(BORLAND)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/amxfloat.def ${CMAKE_BINARY_DIR}/amxfloat.def COPYONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/amxfloat.def
${CMAKE_BINARY_DIR}/amxfloat.def
COPYONLY)
else()
set_target_properties(amxFloat PROPERTIES LINK_FLAGS "/export:amx_FloatInit /export:amx_FloatCleanup")
set_target_properties(amxFloat PROPERTIES LINK_FLAGS
"/export:amx_FloatInit /export:amx_FloatCleanup")
endif()
endif()
if(UNIX)
@ -117,7 +132,8 @@ else()
if(HAVE_FFI_H)
add_library(amxProcess SHARED ${PROCESS_SRCS})
else()
MESSAGE(SEND_ERROR "amxProcess requires libffi; see http://sources.redhat.com/libffi/")
MESSAGE(SEND_ERROR "amxProcess requires libffi,"
"see http://sources.redhat.com/libffi/")
MESSAGE(SEND_ERROR "libffi is not available (foreign function interface)")
endif()
endif()
@ -125,9 +141,12 @@ set_target_properties(amxProcess PROPERTIES PREFIX "")
if(WIN32)
set(PROCESS_SRCS ${PROCESS_SRCS} dllmain.c amxprocess.rc)
if(BORLAND)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/amxprocess.def ${CMAKE_BINARY_DIR}/amxprocess.def COPYONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/amxprocess.def
${CMAKE_BINARY_DIR}/amxprocess.def
COPYONLY)
else()
set_target_properties(amxProcess PROPERTIES LINK_FLAGS "/export:amx_ProcessInit /export:amx_ProcessCleanup")
set_target_properties(amxProcess PROPERTIES LINK_FLAGS
"/export:amx_ProcessInit /export:amx_ProcessCleanup")
endif()
endif()
if(UNIX)
@ -141,9 +160,12 @@ set_target_properties(amxString PROPERTIES PREFIX "")
if(WIN32)
set(STRING_SRCS ${STRING_SRCS} dllmain.c amxstring.rc)
if(BORLAND)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/amxstring.def ${CMAKE_BINARY_DIR}/amxstring.def COPYONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/amxstring.def
${CMAKE_BINARY_DIR}/amxstring.def
COPYONLY)
else()
set_target_properties(amxString PROPERTIES LINK_FLAGS "/export:amx_StringInit /export:amx_StringCleanup")
set_target_properties(amxString PROPERTIES LINK_FLAGS
"/export:amx_StringInit /export:amx_StringCleanup")
endif()
endif()
@ -154,9 +176,12 @@ set_target_properties(amxTime PROPERTIES PREFIX "")
if(WIN32)
set(TIME_SRCS ${TIME_SRCS} dllmain.c amxtime.rc)
if(BORLAND)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/amxtime.def ${CMAKE_BINARY_DIR}/amxtime.def COPYONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/amxtime.def
${CMAKE_BINARY_DIR}/amxtime.def
COPYONLY)
else()
set_target_properties(amxTime PROPERTIES LINK_FLAGS "/export:amx_TimeInit /export:amx_TimeCleanup")
set_target_properties(amxTime PROPERTIES LINK_FLAGS
"/export:amx_TimeInit /export:amx_TimeCleanup")
endif()
endif()
@ -165,10 +190,17 @@ endif()
set(PAWNRUN_SRCS pawnrun.c amx.c amxcore.c amxcons.c amxdbg.c)
if(UNIX)
set(PAWNRUN_SRCS ${PAWNRUN_SRCS} ${CMAKE_CURRENT_SOURCE_DIR}/../linux/getch.c ${CMAKE_CURRENT_SOURCE_DIR}/../linux/binreloc.c)
set(PAWNRUN_SRCS
${PAWNRUN_SRCS}
${CMAKE_CURRENT_SOURCE_DIR}/../linux/getch.c
${CMAKE_CURRENT_SOURCE_DIR}/../linux/binreloc.c
)
endif()
ADD_EXECUTABLE(pawnrun ${PAWNRUN_SRCS})
set_target_properties(pawnrun PROPERTIES COMPILE_FLAGS -DAMXDBG COMPILE_FLAGS -DENABLE_BINRELOC)
set_target_properties(pawnrun PROPERTIES
COMPILE_FLAGS -DAMXDBG
COMPILE_FLAGS -DENABLE_BINRELOC
)
if(UNIX)
target_link_libraries(pawnrun dl)
endif()
@ -178,7 +210,10 @@ endif()
set(PAWNDBG_SRCS pawndbg.c amx.c amxcore.c amxcons.c amxdbg.c)
if(UNIX)
set(PAWNDBG_SRCS ${PAWNDBG_SRCS} ${CMAKE_CURRENT_SOURCE_DIR}/../linux/getch.c ${CMAKE_CURRENT_SOURCE_DIR}/../linux/binreloc.c)
set(PAWNDBG_SRCS
${PAWNDBG_SRCS} ${CMAKE_CURRENT_SOURCE_DIR}/../linux/getch.c
${CMAKE_CURRENT_SOURCE_DIR}/../linux/binreloc.c
)
endif()
ADD_EXECUTABLE(pawndbg ${PAWNDBG_SRCS})
set_target_properties(pawndbg PROPERTIES COMPILE_FLAGS -DENABLE_BINRELOC)

View File

@ -40,7 +40,7 @@ endif()
if(UNIX)
add_definitions(-DLINUX -DENABLE_BINRELOC -g)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../linux)
link_libraries(pthread) #CMake adds the "lib" prefix, so "pthread" becomes "libpthread"
link_libraries(pthread)
endif()
# Append git commit hash to the version string
@ -55,29 +55,48 @@ configure_file(svnrev.h.in svnrev.h)
include_directories(${CMAKE_CURRENT_BINARY_DIR})
# The Pawn compiler shared library
set(PAWNC_SRCS sc1.c sc2.c sc3.c sc4.c sc5.c sc6.c sc7.c
sci18n.c sclist.c scmemfil.c scstate.c scvars.c
lstring.c memfile.c libpawnc.c)
set(PAWNC_SRCS
libpawnc.c
lstring.c
memfile.c
sc1.c
sc2.c
sc3.c
sc4.c
sc5.c
sc6.c
sc7.c
sci18n.c
sclist.c
scmemfil.c
scstate.c
scvars.c)
set_source_files_properties(sc1.c COMPILE_FLAGS -DNO_MAIN)
if(WIN32)
set(PAWNC_SRCS ${PAWNC_SRCS} libpawnc.rc)
set_source_files_properties(libpawnc.c COMPILE_FLAGS -DPAWNC_DLL)
if(BORLAND)
# Borland linker uses a DEF file if one is in the output directory
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libpawnc.def.borland ${CMAKE_BINARY_DIR}/pawnc.def COPYONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libpawnc.def.borland
${CMAKE_BINARY_DIR}/pawnc.def
COPYONLY)
else()
# Microsoft Visual C/C++ supports a DEF file as if it were a source file
set(PAWNC_SRCS ${PAWNC_SRCS} libpawnc.def)
endif()
endif()
if(UNIX)
set(PAWNC_SRCS ${PAWNC_SRCS} ${CMAKE_CURRENT_SOURCE_DIR}/../linux/binreloc.c)
set(PAWNC_SRCS
${PAWNC_SRCS}
${CMAKE_CURRENT_SOURCE_DIR}/../linux/binreloc.c
)
endif()
add_library(pawnc SHARED ${PAWNC_SRCS})
if(WATCOM) #Watcom C/C++ does not support a .DEF file for the exports
set_target_properties(pawnc PROPERTIES LINK_FLAGS "/exp=libpawnc")
elseif(MINGW)
set_target_properties(pawnc PROPERTIES LINK_FLAGS "-Wl,--enable-stdcall-fixup")
set_target_properties(pawnc PROPERTIES LINK_FLAGS
"-Wl,--enable-stdcall-fixup")
endif()
# The Pawn compiler driver (console program)
@ -86,7 +105,9 @@ if(WIN32)
set(PAWNCC_SRCS ${PAWNCC_SRCS} libpawnc.rc)
if(BORLAND)
# Borland linker uses a DEF file if one is in the output directory
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/pawncc.def.borland ${CMAKE_BINARY_DIR}/pawncc.def COPYONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/pawncc.def.borland
${CMAKE_BINARY_DIR}/pawncc.def
COPYONLY)
else()
# Microsoft Visual C/C++ supports a DEF file as if it were a source file
set(PAWNC_SRCS ${PAWNC_SRCS} pawncc.def)
@ -96,7 +117,11 @@ add_executable(pawncc ${PAWNCC_SRCS})
target_link_libraries(pawncc pawnc)
# The Pawn disassembler
set(PAWNDISASM_SRCS pawndisasm.c ../amx/amxdbg.c ../amx/amx.c)
set(PAWNDISASM_SRCS
pawndisasm.c
../amx/amxdbg.c
../amx/amx.c
)
add_executable(pawndisasm ${PAWNDISASM_SRCS})
if(UNIX)
target_link_libraries(pawndisasm dl)