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.8)
PROJECT(pawnamx)
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
# check for optional include files # check for optional include files
INCLUDE(${CMAKE_ROOT}/Modules/CheckIncludeFile.cmake) include(CheckIncludeFile)
CHECK_INCLUDE_FILE("unistd.h" HAVE_UNISTD_H) check_include_file("unistd.h" HAVE_UNISTD_H)
IF(HAVE_UNISTD_H) if(HAVE_UNISTD_H)
ADD_DEFINITIONS(-DHAVE_UNISTD_H) add_definitions(-DHAVE_UNISTD_H)
ENDIF(HAVE_UNISTD_H) endif()
CHECK_INCLUDE_FILE("inttypes.h" HAVE_INTTYPES_H) check_include_file("inttypes.h" HAVE_INTTYPES_H)
IF(HAVE_INTTYPES_H) if(HAVE_INTTYPES_H)
ADD_DEFINITIONS(-DHAVE_INTTYPES_H) add_definitions(-DHAVE_INTTYPES_H)
ENDIF(HAVE_INTTYPES_H) endif()
CHECK_INCLUDE_FILE("stdint.h" HAVE_STDINT_H) check_include_file("stdint.h" HAVE_STDINT_H)
IF(HAVE_STDINT_H) if(HAVE_STDINT_H)
ADD_DEFINITIONS(-DHAVE_STDINT_H) add_definitions(-DHAVE_STDINT_H)
ENDIF(HAVE_STDINT_H) endif()
CHECK_INCLUDE_FILE("alloca.h" HAVE_ALLOCA_H) check_include_file("alloca.h" HAVE_ALLOCA_H)
IF(HAVE_ALLOCA_H) if(HAVE_ALLOCA_H)
ADD_DEFINITIONS(-DHAVE_ALLOCA_H) add_definitions(-DHAVE_ALLOCA_H)
ENDIF(HAVE_ALLOCA_H) endif()
ADD_DEFINITIONS(-DFLOATPOINT -DFIXEDPOINT) add_definitions(-DFLOATPOINT -DFIXEDPOINT)
IF (UNIX) if(UNIX)
ADD_DEFINITIONS(-DLINUX) add_definitions(-DLINUX)
CHECK_INCLUDE_FILE("ffi.h" HAVE_FFI_H) check_include_file("ffi.h" HAVE_FFI_H)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../linux) include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../linux)
ENDIF (UNIX) endif()
IF(WIN32) if(WIN32)
ADD_DEFINITIONS(-DAMXEXPORT=__stdcall -DAMX_NATIVE_CALL=__stdcall -DSTDECL) add_definitions(-DAMXEXPORT=__stdcall -DAMX_NATIVE_CALL=__stdcall -DSTDECL)
IF(NOT BORLAND) if(NOT BORLAND)
LINK_LIBRARIES(winmm) link_libraries(winmm)
ENDIF(NOT BORLAND) endif()
ENDIF(WIN32) endif()
# -------------------------------------------------------------------------- # --------------------------------------------------------------------------
# Extension modules # Extension modules
# amxArgs # amxArgs
SET(ARGS_SRCS amxargs.c amx.c) set(ARGS_SRCS amxargs.c amx.c)
ADD_LIBRARY(amxArgs SHARED ${ARGS_SRCS}) add_library(amxArgs SHARED ${ARGS_SRCS})
SET_TARGET_PROPERTIES(amxArgs PROPERTIES PREFIX "") set_target_properties(amxArgs PROPERTIES PREFIX "")
IF(WIN32) if(WIN32)
SET(ARGS_SRCS ${ARGS_SRCS} dllmain.c amxargs.rc) set(ARGS_SRCS ${ARGS_SRCS} dllmain.c amxargs.rc)
IF(BORLAND) if(BORLAND)
# Borland linker uses a DEF file if one is in the output directory # 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) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/amxargs.def ${CMAKE_BINARY_DIR}/amxargs.def COPY_ONLY)
ELSE(BORLAND) else()
# For Microsoft Visual C/C++ we can set explicit flags for exports # 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(BORLAND) endif()
ENDIF(WIN32) endif()
IF(UNIX) 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) 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) endif()
# amxDGram # amxDGram
SET(DGRAM_SRCS amxdgram.c amx.c) set(DGRAM_SRCS amxdgram.c amx.c)
ADD_LIBRARY(amxDGram SHARED ${DGRAM_SRCS}) add_library(amxDGram SHARED ${DGRAM_SRCS})
SET_TARGET_PROPERTIES(amxDGram PROPERTIES PREFIX "") set_target_properties(amxDGram PROPERTIES PREFIX "")
IF(WIN32) if(WIN32)
SET(DGRAM_SRCS ${DGRAM_SRCS} dllmain.c amxargs.rc) set(DGRAM_SRCS ${DGRAM_SRCS} dllmain.c amxargs.rc)
IF(BORLAND) if(BORLAND)
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/amxdgram.def ${CMAKE_BINARY_DIR}/amxdgram.def COPY_ONLY) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/amxdgram.def ${CMAKE_BINARY_DIR}/amxdgram.def COPY_ONLY)
ELSE(BORLAND) 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(BORLAND) endif()
ENDIF(WIN32) endif()
IF(UNIX) if(UNIX)
ADD_CUSTOM_COMMAND(TARGET amxDGram POST_BUILD COMMAND strip ARGS -K amx_DGramInit -K amx_DGramCleanup ${CMAKE_BINARY_DIR}/amxDGram.so) add_custom_command(TARGET amxDGram POST_BUILD COMMAND strip ARGS -K amx_DGramInit -K amx_DGramCleanup ${CMAKE_BINARY_DIR}/amxDGram.so)
ENDIF(UNIX) endif()
# amxFile # amxFile
SET(FILE_SRCS amxfile.c amx.c) set(FILE_SRCS amxfile.c amx.c)
ADD_LIBRARY(amxFile SHARED ${FILE_SRCS}) add_library(amxFile SHARED ${FILE_SRCS})
SET_TARGET_PROPERTIES(amxFile PROPERTIES PREFIX "") set_target_properties(amxFile PROPERTIES PREFIX "")
IF(WIN32) if(WIN32)
SET(FILE_SRCS ${FILE_SRCS} dllmain.c amxfile.rc) set(FILE_SRCS ${FILE_SRCS} dllmain.c amxfile.rc)
IF(BORLAND) if(BORLAND)
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/amxfile.def ${CMAKE_BINARY_DIR}/amxfile.def COPY_ONLY) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/amxfile.def ${CMAKE_BINARY_DIR}/amxfile.def COPY_ONLY)
ELSE(BORLAND) 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(BORLAND) endif()
ENDIF(WIN32) endif()
IF(UNIX) if(UNIX)
ADD_CUSTOM_COMMAND(TARGET amxFile POST_BUILD COMMAND strip ARGS -K amx_FileInit -K amx_FileCleanup ${CMAKE_BINARY_DIR}/amxFile.so) add_custom_command(TARGET amxFile POST_BUILD COMMAND strip ARGS -K amx_FileInit -K amx_FileCleanup ${CMAKE_BINARY_DIR}/amxFile.so)
ENDIF(UNIX) endif()
# amxFixed # amxFixed
SET(FIXED_SRCS fixed.c amx.c) set(FIXED_SRCS fixed.c amx.c)
ADD_LIBRARY(amxFixed SHARED ${FIXED_SRCS}) add_library(amxFixed SHARED ${FIXED_SRCS})
SET_TARGET_PROPERTIES(amxFixed PROPERTIES PREFIX "") set_target_properties(amxFixed PROPERTIES PREFIX "")
IF(WIN32) if(WIN32)
SET(FIXED_SRCS ${FIXED_SRCS} dllmain.c amxfixed.rc) set(FIXED_SRCS ${FIXED_SRCS} dllmain.c amxfixed.rc)
IF(BORLAND) if(BORLAND)
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/amxfixed.def ${CMAKE_BINARY_DIR}/amxfixed.def COPY_ONLY) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/amxfixed.def ${CMAKE_BINARY_DIR}/amxfixed.def COPY_ONLY)
ELSE(BORLAND) 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(BORLAND) endif()
ENDIF(WIN32) endif()
IF(UNIX) if(UNIX)
TARGET_LINK_LIBRARIES(amxFixed m) 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) add_custom_command(TARGET amxFixed POST_BUILD COMMAND strip ARGS -K amx_FixedInit -K amx_FixedCleanup ${CMAKE_BINARY_DIR}/amxFixed.so)
ENDIF(UNIX) endif()
# amxFloat # amxFloat
SET(FLOAT_SRCS float.c amx.c) set(FLOAT_SRCS float.c amx.c)
ADD_LIBRARY(amxFloat SHARED ${FLOAT_SRCS}) add_library(amxFloat SHARED ${FLOAT_SRCS})
SET_TARGET_PROPERTIES(amxFloat PROPERTIES PREFIX "") set_target_properties(amxFloat PROPERTIES PREFIX "")
IF(WIN32) if(WIN32)
SET(FLOAT_SRCS ${FLOAT_SRCS} dllmain.c amxfloat.rc) set(FLOAT_SRCS ${FLOAT_SRCS} dllmain.c amxfloat.rc)
IF(BORLAND) if(BORLAND)
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/amxfloat.def ${CMAKE_BINARY_DIR}/amxfloat.def COPY_ONLY) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/amxfloat.def ${CMAKE_BINARY_DIR}/amxfloat.def COPY_ONLY)
ELSE(BORLAND) 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(BORLAND) endif()
ENDIF(WIN32) endif()
IF(UNIX) if(UNIX)
TARGET_LINK_LIBRARIES(amxFloat m) 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) add_custom_command(TARGET amxFloat POST_BUILD COMMAND strip ARGS -K amx_FloatInit -K amx_FloatInit ${CMAKE_BINARY_DIR}/amxFloat.so)
ENDIF(UNIX) endif()
# amxProcess # amxProcess
SET(PROCESS_SRCS amxprocess.c amx.c) set(PROCESS_SRCS amxprocess.c amx.c)
IF(WIN32) if(WIN32)
ADD_LIBRARY(amxProcess SHARED ${PROCESS_SRCS}) add_library(amxProcess SHARED ${PROCESS_SRCS})
ELSE(WIN32) else()
IF(HAVE_FFI_H) if(HAVE_FFI_H)
ADD_LIBRARY(amxProcess SHARED ${PROCESS_SRCS}) add_library(amxProcess SHARED ${PROCESS_SRCS})
ELSE(HAVE_FFI_H) 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)") MESSAGE(SEND_ERROR "libffi is not available (foreign function interface)")
ENDIF(HAVE_FFI_H) endif()
ENDIF(WIN32) endif()
SET_TARGET_PROPERTIES(amxProcess PROPERTIES PREFIX "") set_target_properties(amxProcess PROPERTIES PREFIX "")
IF(WIN32) if(WIN32)
SET(PROCESS_SRCS ${PROCESS_SRCS} dllmain.c amxprocess.rc) set(PROCESS_SRCS ${PROCESS_SRCS} dllmain.c amxprocess.rc)
IF(BORLAND) if(BORLAND)
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/amxprocess.def ${CMAKE_BINARY_DIR}/amxprocess.def COPY_ONLY) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/amxprocess.def ${CMAKE_BINARY_DIR}/amxprocess.def COPY_ONLY)
ELSE(BORLAND) 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(BORLAND) endif()
ENDIF(WIN32) endif()
IF(UNIX) if(UNIX)
TARGET_LINK_LIBRARIES(amxProcess dl) 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) add_custom_command(TARGET amxProcess POST_BUILD COMMAND strip ARGS -K amx_ProcessInit -K amx_ProcessCleanup ${CMAKE_BINARY_DIR}/amxProcess.so)
ENDIF(UNIX) endif()
# amxString # amxString
SET(STRING_SRCS amxstring.c amx.c amxcons.c) set(STRING_SRCS amxstring.c amx.c amxcons.c)
ADD_LIBRARY(amxString SHARED ${STRING_SRCS}) add_library(amxString SHARED ${STRING_SRCS})
SET_TARGET_PROPERTIES(amxString PROPERTIES PREFIX "") set_target_properties(amxString PROPERTIES PREFIX "")
IF(WIN32) if(WIN32)
SET(STRING_SRCS ${STRING_SRCS} dllmain.c amxstring.rc) set(STRING_SRCS ${STRING_SRCS} dllmain.c amxstring.rc)
IF(BORLAND) if(BORLAND)
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/amxstring.def ${CMAKE_BINARY_DIR}/amxstring.def COPY_ONLY) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/amxstring.def ${CMAKE_BINARY_DIR}/amxstring.def COPY_ONLY)
ELSE(BORLAND) 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(BORLAND) endif()
ENDIF(WIN32) endif()
IF(UNIX) if(UNIX)
ADD_CUSTOM_COMMAND(TARGET amxString POST_BUILD COMMAND strip ARGS -K amx_StringInit -K amx_StringCleanup ${CMAKE_BINARY_DIR}/amxString.so) add_custom_command(TARGET amxString POST_BUILD COMMAND strip ARGS -K amx_StringInit -K amx_StringCleanup ${CMAKE_BINARY_DIR}/amxString.so)
ENDIF(UNIX) endif()
# amxTime # amxTime
SET(TIME_SRCS amxtime.c amx.c) set(TIME_SRCS amxtime.c amx.c)
ADD_LIBRARY(amxTime SHARED ${TIME_SRCS}) add_library(amxTime SHARED ${TIME_SRCS})
SET_TARGET_PROPERTIES(amxTime PROPERTIES PREFIX "") set_target_properties(amxTime PROPERTIES PREFIX "")
IF(WIN32) if(WIN32)
SET(TIME_SRCS ${TIME_SRCS} dllmain.c amxtime.rc) set(TIME_SRCS ${TIME_SRCS} dllmain.c amxtime.rc)
IF(BORLAND) if(BORLAND)
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/amxtime.def ${CMAKE_BINARY_DIR}/amxtime.def COPY_ONLY) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/amxtime.def ${CMAKE_BINARY_DIR}/amxtime.def COPY_ONLY)
ELSE(BORLAND) 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(BORLAND) endif()
ENDIF(WIN32) endif()
IF(UNIX) if(UNIX)
ADD_CUSTOM_COMMAND(TARGET amxTime POST_BUILD COMMAND strip ARGS -K amx_TimeInit -K amx_TimeCleanup ${CMAKE_BINARY_DIR}/amxTime.so) add_custom_command(TARGET amxTime POST_BUILD COMMAND strip ARGS -K amx_TimeInit -K amx_TimeCleanup ${CMAKE_BINARY_DIR}/amxTime.so)
ENDIF(UNIX) endif()
# -------------------------------------------------------------------------- # --------------------------------------------------------------------------
# Simple run-time (example program) # Simple run-time (example program)
SET(PAWNRUN_SRCS pawnrun.c amx.c amxcore.c amxcons.c amxdbg.c) set(PAWNRUN_SRCS pawnrun.c amx.c amxcore.c amxcons.c amxdbg.c)
IF (UNIX) 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 (UNIX) endif()
ADD_EXECUTABLE(pawnrun ${PAWNRUN_SRCS}) 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) if(UNIX)
TARGET_LINK_LIBRARIES(pawnrun dl) target_link_libraries(pawnrun dl)
ENDIF (UNIX) endif()
# -------------------------------------------------------------------------- # --------------------------------------------------------------------------
# Simple console debugger # Simple console debugger
SET(PAWNDBG_SRCS pawndbg.c amx.c amxcore.c amxcons.c amxdbg.c) set(PAWNDBG_SRCS pawndbg.c amx.c amxcore.c amxcons.c amxdbg.c)
IF (UNIX) 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 (UNIX) endif()
ADD_EXECUTABLE(pawndbg ${PAWNDBG_SRCS}) ADD_EXECUTABLE(pawndbg ${PAWNDBG_SRCS})
SET_TARGET_PROPERTIES(pawndbg PROPERTIES COMPILE_FLAGS -DENABLE_BINRELOC) set_target_properties(pawndbg PROPERTIES COMPILE_FLAGS -DENABLE_BINRELOC)
IF (UNIX) if(UNIX)
TARGET_LINK_LIBRARIES(pawndbg dl) target_link_libraries(pawndbg dl)
ENDIF (UNIX) endif()

View File

@ -1,84 +1,81 @@
#build file for CMake, see http://www.cmake.org/ project(pawnc)
cmake_minimum_required(VERSION 2.8)
PROJECT(pawnc)
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
# check for optional include files # check for optional include files
INCLUDE(${CMAKE_ROOT}/Modules/CheckIncludeFile.cmake) include(CheckIncludeFile)
CHECK_INCLUDE_FILE("unistd.h" HAVE_UNISTD_H) check_include_file("unistd.h" HAVE_UNISTD_H)
IF(HAVE_UNISTD_H) if(HAVE_UNISTD_H)
ADD_DEFINITIONS(-DHAVE_UNISTD_H) add_definitions(-DHAVE_UNISTD_H)
ENDIF(HAVE_UNISTD_H) endif()
CHECK_INCLUDE_FILE("inttypes.h" HAVE_INTTYPES_H) check_include_file("inttypes.h" HAVE_INTTYPES_H)
IF(HAVE_INTTYPES_H) if(HAVE_INTTYPES_H)
ADD_DEFINITIONS(-DHAVE_INTTYPES_H) add_definitions(-DHAVE_INTTYPES_H)
ENDIF(HAVE_INTTYPES_H) endif()
CHECK_INCLUDE_FILE("stdint.h" HAVE_STDINT_H) check_include_file("stdint.h" HAVE_STDINT_H)
IF(HAVE_STDINT_H) if(HAVE_STDINT_H)
ADD_DEFINITIONS(-DHAVE_STDINT_H) add_definitions(-DHAVE_STDINT_H)
ENDIF(HAVE_STDINT_H) endif()
CHECK_INCLUDE_FILE("alloca.h" HAVE_ALLOCA_H) check_include_file("alloca.h" HAVE_ALLOCA_H)
IF(HAVE_ALLOCA_H) if(HAVE_ALLOCA_H)
ADD_DEFINITIONS(-DHAVE_ALLOCA_H) add_definitions(-DHAVE_ALLOCA_H)
ENDIF(HAVE_ALLOCA_H) endif()
IF(MSVC) if(MSVC)
ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS /J) add_definitions(-D_CRT_SECURE_NO_WARNINGS /J)
ENDIF(MSVC) endif()
IF(UNIX) if(UNIX)
ADD_DEFINITIONS(-DLINUX -DENABLE_BINRELOC -g) add_definitions(-DLINUX -DENABLE_BINRELOC -g)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../linux) include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../linux)
LINK_LIBRARIES(pthread) #CMake adds the "lib" prefix, so "pthread" becomes "libpthread" link_libraries(pthread) #CMake adds the "lib" prefix, so "pthread" becomes "libpthread"
ENDIF(UNIX) endif()
# The Pawn compiler shared library # 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 scexpand.c sci18n.c sclist.c scmemfil.c scstate.c scvars.c
lstring.c memfile.c libpawnc.c) lstring.c memfile.c libpawnc.c)
SET_SOURCE_FILES_PROPERTIES(sc1.c COMPILE_FLAGS -DNO_MAIN) set_source_files_properties(sc1.c COMPILE_FLAGS -DNO_MAIN)
IF(WIN32) if(WIN32)
SET(PAWNC_SRCS ${PAWNC_SRCS} libpawnc.rc) set(PAWNC_SRCS ${PAWNC_SRCS} libpawnc.rc)
SET_SOURCE_FILES_PROPERTIES(libpawnc.c COMPILE_FLAGS -DPAWNC_DLL) set_source_files_properties(libpawnc.c COMPILE_FLAGS -DPAWNC_DLL)
IF(BORLAND) if(BORLAND)
# Borland linker uses a DEF file if one is in the output directory # 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) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libpawnc.def.borland ${CMAKE_BINARY_DIR}/pawnc.def COPY_ONLY)
ELSE(BORLAND) else()
# Microsoft Visual C/C++ supports a DEF file as if it were a source file # Microsoft Visual C/C++ supports a DEF file as if it were a source file
SET(PAWNC_SRCS ${PAWNC_SRCS} libpawnc.def) set(PAWNC_SRCS ${PAWNC_SRCS} libpawnc.def)
ENDIF(BORLAND) endif()
ENDIF(WIN32) endif()
IF(UNIX) 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(UNIX) endif()
ADD_LIBRARY(pawnc SHARED ${PAWNC_SRCS}) add_library(pawnc SHARED ${PAWNC_SRCS})
IF(WATCOM) #Watcom C/C++ does not support a .DEF file for the exports if(WATCOM) #Watcom C/C++ does not support a .DEF file for the exports
SET_TARGET_PROPERTIES(pawnc PROPERTIES LINK_FLAGS "/exp=libpawnc") set_target_properties(pawnc PROPERTIES LINK_FLAGS "/exp=libpawnc")
ENDIF(WATCOM) endif()
IF(UNIX AND NOT CMAKE_BUILD_TYPE STREQUAL "Debug") if(UNIX AND NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
# Unix exports all symbols by default; we want only a very select few exported symbols # 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) 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") endif()
# The Pawn compiler driver (console program) # The Pawn compiler driver (console program)
SET(PAWNCC_SRCS pawncc.c) set(PAWNCC_SRCS pawncc.c)
IF(WIN32) if(WIN32)
SET(PAWNCC_SRCS ${PAWNCC_SRCS} libpawnc.rc) set(PAWNCC_SRCS ${PAWNCC_SRCS} libpawnc.rc)
IF(BORLAND) if(BORLAND)
# Borland linker uses a DEF file if one is in the output directory # 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) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/pawncc.def.borland ${CMAKE_BINARY_DIR}/pawncc.def COPY_ONLY)
ELSE(BORLAND) else()
# Microsoft Visual C/C++ supports a DEF file as if it were a source file # Microsoft Visual C/C++ supports a DEF file as if it were a source file
SET(PAWNC_SRCS ${PAWNC_SRCS} pawncc.def) set(PAWNC_SRCS ${PAWNC_SRCS} pawncc.def)
ENDIF(BORLAND) endif()
ENDIF(WIN32) endif()
ADD_EXECUTABLE(pawncc ${PAWNCC_SRCS}) add_executable(pawncc ${PAWNCC_SRCS})
TARGET_LINK_LIBRARIES(pawncc pawnc) target_link_libraries(pawncc pawnc)
# The Pawn disassembler # 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}) add_executable(pawndisasm ${PAWNDISASM_SRCS})
IF(UNIX) if(UNIX)
TARGET_LINK_LIBRARIES(pawndisasm dl) target_link_libraries(pawndisasm dl)
ENDIF(UNIX) endif()