Modernize CMakeLists.txt

This commit is contained in:
Zeex 2015-04-02 15:20:27 +06:00
parent 3c22187fb4
commit c36b495c36
2 changed files with 233 additions and 239 deletions

View File

@ -1,208 +1,205 @@
#build file for CMake, see http://www.cmake.org/
PROJECT(pawnamx)
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
project(pawnamx)
cmake_minimum_required(VERSION 2.8)
# check for optional include files
INCLUDE(${CMAKE_ROOT}/Modules/CheckIncludeFile.cmake)
CHECK_INCLUDE_FILE("unistd.h" HAVE_UNISTD_H)
IF(HAVE_UNISTD_H)
ADD_DEFINITIONS(-DHAVE_UNISTD_H)
ENDIF(HAVE_UNISTD_H)
CHECK_INCLUDE_FILE("inttypes.h" HAVE_INTTYPES_H)
IF(HAVE_INTTYPES_H)
ADD_DEFINITIONS(-DHAVE_INTTYPES_H)
ENDIF(HAVE_INTTYPES_H)
CHECK_INCLUDE_FILE("stdint.h" HAVE_STDINT_H)
IF(HAVE_STDINT_H)
ADD_DEFINITIONS(-DHAVE_STDINT_H)
ENDIF(HAVE_STDINT_H)
CHECK_INCLUDE_FILE("alloca.h" HAVE_ALLOCA_H)
IF(HAVE_ALLOCA_H)
ADD_DEFINITIONS(-DHAVE_ALLOCA_H)
ENDIF(HAVE_ALLOCA_H)
include(CheckIncludeFile)
check_include_file("unistd.h" HAVE_UNISTD_H)
if(HAVE_UNISTD_H)
add_definitions(-DHAVE_UNISTD_H)
endif()
check_include_file("inttypes.h" HAVE_INTTYPES_H)
if(HAVE_INTTYPES_H)
add_definitions(-DHAVE_INTTYPES_H)
endif()
check_include_file("stdint.h" HAVE_STDINT_H)
if(HAVE_STDINT_H)
add_definitions(-DHAVE_STDINT_H)
endif()
check_include_file("alloca.h" HAVE_ALLOCA_H)
if(HAVE_ALLOCA_H)
add_definitions(-DHAVE_ALLOCA_H)
endif()
ADD_DEFINITIONS(-DFLOATPOINT -DFIXEDPOINT)
IF (UNIX)
ADD_DEFINITIONS(-DLINUX)
CHECK_INCLUDE_FILE("ffi.h" HAVE_FFI_H)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../linux)
ENDIF (UNIX)
IF(WIN32)
ADD_DEFINITIONS(-DAMXEXPORT=__stdcall -DAMX_NATIVE_CALL=__stdcall -DSTDECL)
IF(NOT BORLAND)
LINK_LIBRARIES(winmm)
ENDIF(NOT BORLAND)
ENDIF(WIN32)
add_definitions(-DFLOATPOINT -DFIXEDPOINT)
if(UNIX)
add_definitions(-DLINUX)
check_include_file("ffi.h" HAVE_FFI_H)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../linux)
endif()
if(WIN32)
add_definitions(-DAMXEXPORT=__stdcall -DAMX_NATIVE_CALL=__stdcall -DSTDECL)
if(NOT BORLAND)
link_libraries(winmm)
endif()
endif()
# --------------------------------------------------------------------------
# Extension modules
# amxArgs
SET(ARGS_SRCS amxargs.c amx.c)
ADD_LIBRARY(amxArgs SHARED ${ARGS_SRCS})
SET_TARGET_PROPERTIES(amxArgs PROPERTIES PREFIX "")
IF(WIN32)
SET(ARGS_SRCS ${ARGS_SRCS} dllmain.c amxargs.rc)
IF(BORLAND)
set(ARGS_SRCS amxargs.c amx.c)
add_library(amxArgs SHARED ${ARGS_SRCS})
set_target_properties(amxArgs PROPERTIES PREFIX "")
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 COPY_ONLY)
ELSE(BORLAND)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/amxargs.def ${CMAKE_BINARY_DIR}/amxargs.def COPY_ONLY)
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")
ENDIF(BORLAND)
ENDIF(WIN32)
IF(UNIX)
ADD_CUSTOM_COMMAND(TARGET amxArgs POST_BUILD COMMAND strip ARGS -K amx_ArgsInit -K amx_ArgsCleanup -K amx_ArgsSetCmdLine ${CMAKE_BINARY_DIR}/amxArgs.so)
ENDIF(UNIX)
set_target_properties(amxArgs PROPERTIES LINK_FLAGS "/export:amx_ArgsInit /export:amx_ArgsCleanup /export:amx_ArgsSetCmdLine")
endif()
endif()
if(UNIX)
add_custom_command(TARGET amxArgs POST_BUILD COMMAND strip ARGS -K amx_ArgsInit -K amx_ArgsCleanup -K amx_ArgsSetCmdLine ${CMAKE_BINARY_DIR}/amxArgs.so)
endif()
# amxDGram
SET(DGRAM_SRCS amxdgram.c amx.c)
ADD_LIBRARY(amxDGram SHARED ${DGRAM_SRCS})
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 COPY_ONLY)
ELSE(BORLAND)
SET_TARGET_PROPERTIES(amxDGram PROPERTIES LINK_FLAGS "/export:amx_DGramInit /export:amx_DGramCleanup")
ENDIF(BORLAND)
ENDIF(WIN32)
IF(UNIX)
ADD_CUSTOM_COMMAND(TARGET amxDGram POST_BUILD COMMAND strip ARGS -K amx_DGramInit -K amx_DGramCleanup ${CMAKE_BINARY_DIR}/amxDGram.so)
ENDIF(UNIX)
set(DGRAM_SRCS amxdgram.c amx.c)
add_library(amxDGram SHARED ${DGRAM_SRCS})
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 COPY_ONLY)
else()
set_target_properties(amxDGram PROPERTIES LINK_FLAGS "/export:amx_DGramInit /export:amx_DGramCleanup")
endif()
endif()
if(UNIX)
add_custom_command(TARGET amxDGram POST_BUILD COMMAND strip ARGS -K amx_DGramInit -K amx_DGramCleanup ${CMAKE_BINARY_DIR}/amxDGram.so)
endif()
# amxFile
SET(FILE_SRCS amxfile.c amx.c)
ADD_LIBRARY(amxFile SHARED ${FILE_SRCS})
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 COPY_ONLY)
ELSE(BORLAND)
SET_TARGET_PROPERTIES(amxFile PROPERTIES LINK_FLAGS "/export:amx_FileInit /export:amx_FileCleanup")
ENDIF(BORLAND)
ENDIF(WIN32)
IF(UNIX)
ADD_CUSTOM_COMMAND(TARGET amxFile POST_BUILD COMMAND strip ARGS -K amx_FileInit -K amx_FileCleanup ${CMAKE_BINARY_DIR}/amxFile.so)
ENDIF(UNIX)
set(FILE_SRCS amxfile.c amx.c)
add_library(amxFile SHARED ${FILE_SRCS})
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 COPY_ONLY)
else()
set_target_properties(amxFile PROPERTIES LINK_FLAGS "/export:amx_FileInit /export:amx_FileCleanup")
endif()
endif()
if(UNIX)
add_custom_command(TARGET amxFile POST_BUILD COMMAND strip ARGS -K amx_FileInit -K amx_FileCleanup ${CMAKE_BINARY_DIR}/amxFile.so)
endif()
# amxFixed
SET(FIXED_SRCS fixed.c amx.c)
ADD_LIBRARY(amxFixed SHARED ${FIXED_SRCS})
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 COPY_ONLY)
ELSE(BORLAND)
SET_TARGET_PROPERTIES(amxFixed PROPERTIES LINK_FLAGS "/export:amx_FixedInit /export:amx_FixedCleanup")
ENDIF(BORLAND)
ENDIF(WIN32)
IF(UNIX)
TARGET_LINK_LIBRARIES(amxFixed m)
ADD_CUSTOM_COMMAND(TARGET amxFixed POST_BUILD COMMAND strip ARGS -K amx_FixedInit -K amx_FixedCleanup ${CMAKE_BINARY_DIR}/amxFixed.so)
ENDIF(UNIX)
set(FIXED_SRCS fixed.c amx.c)
add_library(amxFixed SHARED ${FIXED_SRCS})
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 COPY_ONLY)
else()
set_target_properties(amxFixed PROPERTIES LINK_FLAGS "/export:amx_FixedInit /export:amx_FixedCleanup")
endif()
endif()
if(UNIX)
target_link_libraries(amxFixed m)
add_custom_command(TARGET amxFixed POST_BUILD COMMAND strip ARGS -K amx_FixedInit -K amx_FixedCleanup ${CMAKE_BINARY_DIR}/amxFixed.so)
endif()
# amxFloat
SET(FLOAT_SRCS float.c amx.c)
ADD_LIBRARY(amxFloat SHARED ${FLOAT_SRCS})
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 COPY_ONLY)
ELSE(BORLAND)
SET_TARGET_PROPERTIES(amxFloat PROPERTIES LINK_FLAGS "/export:amx_FloatInit /export:amx_FloatCleanup")
ENDIF(BORLAND)
ENDIF(WIN32)
IF(UNIX)
TARGET_LINK_LIBRARIES(amxFloat m)
ADD_CUSTOM_COMMAND(TARGET amxFloat POST_BUILD COMMAND strip ARGS -K amx_FloatInit -K amx_FloatInit ${CMAKE_BINARY_DIR}/amxFloat.so)
ENDIF(UNIX)
set(FLOAT_SRCS float.c amx.c)
add_library(amxFloat SHARED ${FLOAT_SRCS})
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 COPY_ONLY)
else()
set_target_properties(amxFloat PROPERTIES LINK_FLAGS "/export:amx_FloatInit /export:amx_FloatCleanup")
endif()
endif()
if(UNIX)
target_link_libraries(amxFloat m)
add_custom_command(TARGET amxFloat POST_BUILD COMMAND strip ARGS -K amx_FloatInit -K amx_FloatInit ${CMAKE_BINARY_DIR}/amxFloat.so)
endif()
# amxProcess
SET(PROCESS_SRCS amxprocess.c amx.c)
IF(WIN32)
ADD_LIBRARY(amxProcess SHARED ${PROCESS_SRCS})
ELSE(WIN32)
IF(HAVE_FFI_H)
ADD_LIBRARY(amxProcess SHARED ${PROCESS_SRCS})
ELSE(HAVE_FFI_H)
set(PROCESS_SRCS amxprocess.c amx.c)
if(WIN32)
add_library(amxProcess SHARED ${PROCESS_SRCS})
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 "libffi is not available (foreign function interface)")
ENDIF(HAVE_FFI_H)
ENDIF(WIN32)
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 COPY_ONLY)
ELSE(BORLAND)
SET_TARGET_PROPERTIES(amxProcess PROPERTIES LINK_FLAGS "/export:amx_ProcessInit /export:amx_ProcessCleanup")
ENDIF(BORLAND)
ENDIF(WIN32)
IF(UNIX)
TARGET_LINK_LIBRARIES(amxProcess dl)
ADD_CUSTOM_COMMAND(TARGET amxProcess POST_BUILD COMMAND strip ARGS -K amx_ProcessInit -K amx_ProcessCleanup ${CMAKE_BINARY_DIR}/amxProcess.so)
ENDIF(UNIX)
endif()
endif()
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 COPY_ONLY)
else()
set_target_properties(amxProcess PROPERTIES LINK_FLAGS "/export:amx_ProcessInit /export:amx_ProcessCleanup")
endif()
endif()
if(UNIX)
target_link_libraries(amxProcess dl)
add_custom_command(TARGET amxProcess POST_BUILD COMMAND strip ARGS -K amx_ProcessInit -K amx_ProcessCleanup ${CMAKE_BINARY_DIR}/amxProcess.so)
endif()
# amxString
SET(STRING_SRCS amxstring.c amx.c amxcons.c)
ADD_LIBRARY(amxString SHARED ${STRING_SRCS})
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 COPY_ONLY)
ELSE(BORLAND)
SET_TARGET_PROPERTIES(amxString PROPERTIES LINK_FLAGS "/export:amx_StringInit /export:amx_StringCleanup")
ENDIF(BORLAND)
ENDIF(WIN32)
IF(UNIX)
ADD_CUSTOM_COMMAND(TARGET amxString POST_BUILD COMMAND strip ARGS -K amx_StringInit -K amx_StringCleanup ${CMAKE_BINARY_DIR}/amxString.so)
ENDIF(UNIX)
set(STRING_SRCS amxstring.c amx.c amxcons.c)
add_library(amxString SHARED ${STRING_SRCS})
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 COPY_ONLY)
else()
set_target_properties(amxString PROPERTIES LINK_FLAGS "/export:amx_StringInit /export:amx_StringCleanup")
endif()
endif()
if(UNIX)
add_custom_command(TARGET amxString POST_BUILD COMMAND strip ARGS -K amx_StringInit -K amx_StringCleanup ${CMAKE_BINARY_DIR}/amxString.so)
endif()
# amxTime
SET(TIME_SRCS amxtime.c amx.c)
ADD_LIBRARY(amxTime SHARED ${TIME_SRCS})
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 COPY_ONLY)
ELSE(BORLAND)
SET_TARGET_PROPERTIES(amxTime PROPERTIES LINK_FLAGS "/export:amx_TimeInit /export:amx_TimeCleanup")
ENDIF(BORLAND)
ENDIF(WIN32)
IF(UNIX)
ADD_CUSTOM_COMMAND(TARGET amxTime POST_BUILD COMMAND strip ARGS -K amx_TimeInit -K amx_TimeCleanup ${CMAKE_BINARY_DIR}/amxTime.so)
ENDIF(UNIX)
set(TIME_SRCS amxtime.c amx.c)
add_library(amxTime SHARED ${TIME_SRCS})
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 COPY_ONLY)
else()
set_target_properties(amxTime PROPERTIES LINK_FLAGS "/export:amx_TimeInit /export:amx_TimeCleanup")
endif()
endif()
if(UNIX)
add_custom_command(TARGET amxTime POST_BUILD COMMAND strip ARGS -K amx_TimeInit -K amx_TimeCleanup ${CMAKE_BINARY_DIR}/amxTime.so)
endif()
# --------------------------------------------------------------------------
# Simple run-time (example program)
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)
ENDIF (UNIX)
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)
endif()
ADD_EXECUTABLE(pawnrun ${PAWNRUN_SRCS})
SET_TARGET_PROPERTIES(pawnrun PROPERTIES COMPILE_FLAGS -DAMXDBG COMPILE_FLAGS -DENABLE_BINRELOC)
IF (UNIX)
TARGET_LINK_LIBRARIES(pawnrun dl)
ENDIF (UNIX)
set_target_properties(pawnrun PROPERTIES COMPILE_FLAGS -DAMXDBG COMPILE_FLAGS -DENABLE_BINRELOC)
if(UNIX)
target_link_libraries(pawnrun dl)
endif()
# --------------------------------------------------------------------------
# Simple console debugger
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)
ENDIF (UNIX)
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)
endif()
ADD_EXECUTABLE(pawndbg ${PAWNDBG_SRCS})
SET_TARGET_PROPERTIES(pawndbg PROPERTIES COMPILE_FLAGS -DENABLE_BINRELOC)
IF (UNIX)
TARGET_LINK_LIBRARIES(pawndbg dl)
ENDIF (UNIX)
set_target_properties(pawndbg PROPERTIES COMPILE_FLAGS -DENABLE_BINRELOC)
if(UNIX)
target_link_libraries(pawndbg dl)
endif()

View File

@ -1,84 +1,81 @@
#build file for CMake, see http://www.cmake.org/
PROJECT(pawnc)
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
project(pawnc)
cmake_minimum_required(VERSION 2.8)
# check for optional include files
INCLUDE(${CMAKE_ROOT}/Modules/CheckIncludeFile.cmake)
CHECK_INCLUDE_FILE("unistd.h" HAVE_UNISTD_H)
IF(HAVE_UNISTD_H)
ADD_DEFINITIONS(-DHAVE_UNISTD_H)
ENDIF(HAVE_UNISTD_H)
CHECK_INCLUDE_FILE("inttypes.h" HAVE_INTTYPES_H)
IF(HAVE_INTTYPES_H)
ADD_DEFINITIONS(-DHAVE_INTTYPES_H)
ENDIF(HAVE_INTTYPES_H)
CHECK_INCLUDE_FILE("stdint.h" HAVE_STDINT_H)
IF(HAVE_STDINT_H)
ADD_DEFINITIONS(-DHAVE_STDINT_H)
ENDIF(HAVE_STDINT_H)
CHECK_INCLUDE_FILE("alloca.h" HAVE_ALLOCA_H)
IF(HAVE_ALLOCA_H)
ADD_DEFINITIONS(-DHAVE_ALLOCA_H)
ENDIF(HAVE_ALLOCA_H)
include(CheckIncludeFile)
check_include_file("unistd.h" HAVE_UNISTD_H)
if(HAVE_UNISTD_H)
add_definitions(-DHAVE_UNISTD_H)
endif()
check_include_file("inttypes.h" HAVE_INTTYPES_H)
if(HAVE_INTTYPES_H)
add_definitions(-DHAVE_INTTYPES_H)
endif()
check_include_file("stdint.h" HAVE_STDINT_H)
if(HAVE_STDINT_H)
add_definitions(-DHAVE_STDINT_H)
endif()
check_include_file("alloca.h" HAVE_ALLOCA_H)
if(HAVE_ALLOCA_H)
add_definitions(-DHAVE_ALLOCA_H)
endif()
IF(MSVC)
ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS /J)
ENDIF(MSVC)
if(MSVC)
add_definitions(-D_CRT_SECURE_NO_WARNINGS /J)
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"
ENDIF(UNIX)
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"
endif()
# The Pawn compiler shared library
SET(PAWNC_SRCS sc1.c sc2.c sc3.c sc4.c sc5.c sc6.c sc7.c
set(PAWNC_SRCS sc1.c sc2.c sc3.c sc4.c sc5.c sc6.c sc7.c
scexpand.c sci18n.c sclist.c scmemfil.c scstate.c scvars.c
lstring.c memfile.c libpawnc.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)
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 COPY_ONLY)
ELSE(BORLAND)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libpawnc.def.borland ${CMAKE_BINARY_DIR}/pawnc.def COPY_ONLY)
else()
# Microsoft Visual C/C++ supports a DEF file as if it were a source file
SET(PAWNC_SRCS ${PAWNC_SRCS} libpawnc.def)
ENDIF(BORLAND)
ENDIF(WIN32)
IF(UNIX)
SET(PAWNC_SRCS ${PAWNC_SRCS} ${CMAKE_CURRENT_SOURCE_DIR}/../linux/binreloc.c)
ENDIF(UNIX)
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")
ENDIF(WATCOM)
IF(UNIX AND NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
set(PAWNC_SRCS ${PAWNC_SRCS} libpawnc.def)
endif()
endif()
if(UNIX)
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")
endif()
if(UNIX AND NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
# Unix exports all symbols by default; we want only a very select few exported symbols
ADD_CUSTOM_COMMAND(TARGET pawnc POST_BUILD COMMAND strip ARGS -K pc_compile -K pc_addconstant -K pc_addtag -K pc_enablewarning ${CMAKE_BINARY_DIR}/libpawnc.so)
ENDIF(UNIX AND NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
add_custom_command(TARGET pawnc POST_BUILD COMMAND strip ARGS -K pc_compile -K pc_addconstant -K pc_addtag -K pc_enablewarning ${CMAKE_BINARY_DIR}/libpawnc.so)
endif()
# The Pawn compiler driver (console program)
SET(PAWNCC_SRCS pawncc.c)
IF(WIN32)
SET(PAWNCC_SRCS ${PAWNCC_SRCS} libpawnc.rc)
IF(BORLAND)
set(PAWNCC_SRCS pawncc.c)
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 COPY_ONLY)
ELSE(BORLAND)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/pawncc.def.borland ${CMAKE_BINARY_DIR}/pawncc.def COPY_ONLY)
else()
# Microsoft Visual C/C++ supports a DEF file as if it were a source file
SET(PAWNC_SRCS ${PAWNC_SRCS} pawncc.def)
ENDIF(BORLAND)
ENDIF(WIN32)
ADD_EXECUTABLE(pawncc ${PAWNCC_SRCS})
TARGET_LINK_LIBRARIES(pawncc pawnc)
set(PAWNC_SRCS ${PAWNC_SRCS} pawncc.def)
endif()
endif()
add_executable(pawncc ${PAWNCC_SRCS})
target_link_libraries(pawncc pawnc)
# The Pawn disassembler
SET(PAWNDISASM_SRCS pawndisasm.c ../amx/amxdbg.c ../amx/amx.c)
ADD_EXECUTABLE(pawndisasm ${PAWNDISASM_SRCS})
IF(UNIX)
TARGET_LINK_LIBRARIES(pawndisasm dl)
ENDIF(UNIX)
set(PAWNDISASM_SRCS pawndisasm.c ../amx/amxdbg.c ../amx/amx.c)
add_executable(pawndisasm ${PAWNDISASM_SRCS})
if(UNIX)
target_link_libraries(pawndisasm dl)
endif()