Skip to content

Commit

Permalink
Add CMakeList.txt and Makefile.cwpack files.
Browse files Browse the repository at this point in the history
Change-Id: I4a47485a6a7bc27e364f0a73e82c76d886e8dc9b
  • Loading branch information
qiaojbao committed Aug 29, 2019
1 parent 43583ff commit 86999e2
Show file tree
Hide file tree
Showing 2 changed files with 107 additions and 0 deletions.
63 changes: 63 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
##
#######################################################################################################################
#
# Modifications Copyright© 2019 Advanced Micro Devices, Inc. All rights reserved.
#
#######################################################################################################################

cmake_minimum_required(VERSION 3.1)

project(CWPACK C)

### Create CWPACK Library ############################################################################################
add_library(cwpack STATIC "")

### Cached Project Options #############################################################################################
# No exposed CWPACK options

### Compiler Options ###################################################################################################
if(WIN32)
if(CMAKE_C_COMPILER_ID STREQUAL "MSVC")
message(STATUS "Configured ${PROJECT_NAME} compiler options for MSVC.")
else()
message(FATAL_ERROR "Using unknown compiler")
endif()
elseif(UNIX)
if(CMAKE_C_COMPILER_ID MATCHES "GNU")
# SEE: https://gcc.gnu.org/onlinedocs/gcc-6.2.0/gcc/Option-Summary.html#Option-Summary
# for a list of all options and documentation.
target_compile_options(cwpack PRIVATE -pthread -fPIC)

message(STATUS "Configured ${PROJECT_NAME} compiler options for GCC.")
elseif(CMAKE_C_COMPILER_ID MATCHES "Clang")
message(WARNING "Clang is untested.")
target_compile_options(cwpack PRIVATE -pthread -fPIC)
else()
message(FATAL_ERROR "Using unknown compiler.")
endif()
endif()

### Defines/Includes/Sources ###########################################################################################
target_compile_definitions(cwpack PRIVATE COMPILE_FOR_${TARGET_ARCHITECTURE_ENDIANESS}_ENDIAN)

if(WIN32)
if(TARGET_ARCHITECTURE_BITS EQUAL 32)
target_compile_definitions(cwpack PRIVATE CWP_CALL=__fastcall)
endif()
endif()

target_include_directories(cwpack PUBLIC src)

target_sources(cwpack PRIVATE src/cwpack.c)

### Link Libraries #####################################################################################################
# No external libraries required for CWPACK.

### Find headers and build source groups ###############################################################################
#target_find_headers(cwpack)
#target_source_groups(cwpack)

### Mark all options as advanced #######################################################################################
if(CWPACK_OPTIONS_MARK_ADVANCED)
mark_grouped_as_advanced(CWPACK)
endif()
44 changes: 44 additions & 0 deletions make/Makefile.cwpack
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
####
#
# Modifications Copyright© 2019 Advanced Micro Devices, Inc. All rights reserved.
#
####

#-----------------------------------------------------------------------
# Common CWPack Implementation Files
#-----------------------------------------------------------------------

vpath %.c $(CWPACK_DEPTH)/src

CFILES += cwpack.c

#-----------------------------------------------------------------------
# Common CWPack Includes
#-----------------------------------------------------------------------

LCINCS += -I$(CWPACK_DEPTH)/src
LCXXINCS += -I$(CWPACK_DEPTH)/src

#-----------------------------------------------------------------------
# Common CWPack Build Options
#-----------------------------------------------------------------------

ifneq ($(filter lnx lnx64a, $(CWPACK_OS_BUILD)),)
LCOPTS += -fPIC
endif

#-----------------------------------------------------------------------
# Common CWPack Defines
#-----------------------------------------------------------------------

LCDEFS += -DCOMPILE_FOR_LITTLE_ENDIAN=1

ifneq ($(filter wNow wNxt, $(CWPACK_OS_BUILD)),)
ifneq ($(filter /Gr, $(LCXXOPTS)),)
LCDEFS += -DCWP_CALL=__fastcall
else
ifneq ($(filter /Gz, $(LCXXOPTS)),)
LCDEFS += -DCWP_CALL=__stdcall
endif
endif
endif

0 comments on commit 86999e2

Please sign in to comment.