<commit_before>PROJECT(libcpu)

CMAKE_MINIMUM_REQUIRED(VERSION 2.8)

INCLUDE(FindThreads)

#
# 
#
SET(CMAKE_BUILD_TYPE "Debug")

#
# Add here the architecture you want to support.
# 
SET(GUEST_ARCHITECTURES 6502 m68k m88k mips arm x86 fapra)
SET(GUEST_EXTRA_TESTS multi)
IF(APPLE)
  SET(GUEST_EXTRA_TESTS ${GUEST_EXTRA_TESTS} next68k)
ENDIF(APPLE)

#
# Build Universal image.
#
IF(APPLE)
  OPTION(UNIVERSAL "Build Universal Executable" OFF)
ENDIF(APPLE)

IF(APPLE AND UNIVERSAL)
	INCLUDE(CMake/AppleMultiArch.cmake)
ENDIF()

#
# Find LLVM, we need it.
#
SET(LLVM_FIND_REQUIRED TRUE)
INCLUDE(CMake/FindLLVM.cmake)

INCLUDE(CMake/BuildConfigH.cmake)
IF(MSVC)
	add_definitions(-D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_WARNINGS -D_SCL_SECURE_NO_WARNINGS -Dinline=__inline)
	# disable warnings for LLVM
	add_definitions(-wd4146) # unary minus operator applied to unsigned type, result still unsigned
	add_definitions(-wd4800) # forcing value to bool 'true' or 'false' (performance warning)
	add_definitions(-wd4355) # 'this' : used in base member initializer list
	include_directories(libcpu/win32/msvc)
ENDIF()

#
# Find Python.
#
INCLUDE(FindPythonInterp)
IF(NOT PYTHONINTERP_FOUND)
	message(FATAL_ERROR "Could not find Python, but Python 2.6 or later is required")
ENDIF()


SET(LIBCPU_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/libcpu)

#
#
#
INCLUDE_DIRECTORIES(${LLVM_INCLUDE_DIR} ${PROJECT_SOURCE_DIR} ${PROJECT_SOURCE_DIR}/libcpu)
LINK_DIRECTORIES(${LLVM_LIB_DIR})
# Add LLVM flags only to C++.
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${LLVM_COMPILE_FLAGS}")

MACRO(TARGET_LINK_LLVM TARGET)
  TARGET_LINK_LIBRARIES(${TARGET} ${LLVM_LDFLAGS} ${LLVM_LIBS_CORE} ${LLVM_LIBS_JIT} ${LLVM_LIBS_JIT_OBJECTS})
ENDMACRO(TARGET_LINK_LLVM)

#
# Add extra warnings for gcc/g++.
#
IF(CMAKE_COMPILER_IS_GNUCXX)
  ADD_DEFINITIONS(-W -Wall -Wextra -Wno-unused -Wno-unused-parameter -D__STDC_FORMAT_MACROS=1)
ENDIF()

FOREACH(ARCHITECTURE ${GUEST_ARCHITECTURES})
	IF(EXISTS ${PROJECT_SOURCE_DIR}/arch/${ARCHITECTURE})
		MESSAGE("** Building Guest Architecture: ${ARCHITECTURE}")
		ADD_SUBDIRECTORY(${PROJECT_SOURCE_DIR}/arch/${ARCHITECTURE})
		INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/arch/${ARCHITECTURE})
		IF(EXISTS ${PROJECT_SOURCE_DIR}/test/${ARCHITECTURE})
			MESSAGE("** Building Test: ${ARCHITECTURE}")
			ADD_SUBDIRECTORY(${PROJECT_SOURCE_DIR}/test/${ARCHITECTURE})
		ENDIF()
    SET(GUEST_ARCHITECTURES_ENABLED "${GUEST_ARCHITECTURES_ENABLED};${ARCHITECTURE}")
	ELSE()
		MESSAGE("** Disabling Guest Architecture: ${ARCHITECTURE}")
	ENDIF()
ENDFOREACH()

FOREACH(TEST ${GUEST_EXTRA_TESTS})
	IF(EXISTS ${PROJECT_SOURCE_DIR}/test/${TEST})
		MESSAGE("** Building Test: ${TEST}")
		ADD_SUBDIRECTORY(${PROJECT_SOURCE_DIR}/test/${TEST})
	ENDIF()
ENDFOREACH()

ADD_SUBDIRECTORY(libcpu)
# ADD_SUBDIRECTORY(upcl)
IF(NOT MSVC)
  ADD_SUBDIRECTORY(test/libloader)
  ADD_SUBDIRECTORY(test/libnix)
ENDIF()

<commit_msg>build: Compile with -fPIC to fix link errors<commit_after>PROJECT(libcpu)

CMAKE_MINIMUM_REQUIRED(VERSION 2.8)

INCLUDE(FindThreads)

#
# 
#
SET(CMAKE_BUILD_TYPE "Debug")

#
# Add here the architecture you want to support.
# 
SET(GUEST_ARCHITECTURES 6502 m68k m88k mips arm x86 fapra)
SET(GUEST_EXTRA_TESTS multi)
IF(APPLE)
  SET(GUEST_EXTRA_TESTS ${GUEST_EXTRA_TESTS} next68k)
ENDIF(APPLE)

#
# Build Universal image.
#
IF(APPLE)
  OPTION(UNIVERSAL "Build Universal Executable" OFF)
ENDIF(APPLE)

IF(APPLE AND UNIVERSAL)
	INCLUDE(CMake/AppleMultiArch.cmake)
ENDIF()

#
# Find LLVM, we need it.
#
SET(LLVM_FIND_REQUIRED TRUE)
INCLUDE(CMake/FindLLVM.cmake)

INCLUDE(CMake/BuildConfigH.cmake)
IF(MSVC)
	add_definitions(-D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_WARNINGS -D_SCL_SECURE_NO_WARNINGS -Dinline=__inline)
	# disable warnings for LLVM
	add_definitions(-wd4146) # unary minus operator applied to unsigned type, result still unsigned
	add_definitions(-wd4800) # forcing value to bool 'true' or 'false' (performance warning)
	add_definitions(-wd4355) # 'this' : used in base member initializer list
	include_directories(libcpu/win32/msvc)
ENDIF()

#
# Find Python.
#
INCLUDE(FindPythonInterp)
IF(NOT PYTHONINTERP_FOUND)
	message(FATAL_ERROR "Could not find Python, but Python 2.6 or later is required")
ENDIF()


SET(LIBCPU_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/libcpu)

#
#
#
INCLUDE_DIRECTORIES(${LLVM_INCLUDE_DIR} ${PROJECT_SOURCE_DIR} ${PROJECT_SOURCE_DIR}/libcpu)
LINK_DIRECTORIES(${LLVM_LIB_DIR})
# Add LLVM flags only to C++.
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${LLVM_COMPILE_FLAGS}")

MACRO(TARGET_LINK_LLVM TARGET)
  TARGET_LINK_LIBRARIES(${TARGET} ${LLVM_LDFLAGS} ${LLVM_LIBS_CORE} ${LLVM_LIBS_JIT} ${LLVM_LIBS_JIT_OBJECTS})
ENDMACRO(TARGET_LINK_LLVM)

#
# Add extra warnings for gcc/g++.
#
IF(CMAKE_COMPILER_IS_GNUCXX)
  ADD_DEFINITIONS(-W -Wall -Wextra -Wno-unused -Wno-unused-parameter -D__STDC_FORMAT_MACROS=1 -fPIC)
ENDIF()

FOREACH(ARCHITECTURE ${GUEST_ARCHITECTURES})
	IF(EXISTS ${PROJECT_SOURCE_DIR}/arch/${ARCHITECTURE})
		MESSAGE("** Building Guest Architecture: ${ARCHITECTURE}")
		ADD_SUBDIRECTORY(${PROJECT_SOURCE_DIR}/arch/${ARCHITECTURE})
		INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/arch/${ARCHITECTURE})
		IF(EXISTS ${PROJECT_SOURCE_DIR}/test/${ARCHITECTURE})
			MESSAGE("** Building Test: ${ARCHITECTURE}")
			ADD_SUBDIRECTORY(${PROJECT_SOURCE_DIR}/test/${ARCHITECTURE})
		ENDIF()
    SET(GUEST_ARCHITECTURES_ENABLED "${GUEST_ARCHITECTURES_ENABLED};${ARCHITECTURE}")
	ELSE()
		MESSAGE("** Disabling Guest Architecture: ${ARCHITECTURE}")
	ENDIF()
ENDFOREACH()

FOREACH(TEST ${GUEST_EXTRA_TESTS})
	IF(EXISTS ${PROJECT_SOURCE_DIR}/test/${TEST})
		MESSAGE("** Building Test: ${TEST}")
		ADD_SUBDIRECTORY(${PROJECT_SOURCE_DIR}/test/${TEST})
	ENDIF()
ENDFOREACH()

ADD_SUBDIRECTORY(libcpu)
# ADD_SUBDIRECTORY(upcl)
IF(NOT MSVC)
  ADD_SUBDIRECTORY(test/libloader)
  ADD_SUBDIRECTORY(test/libnix)
ENDIF()


{'fraction_non_alphanumeric': 0.12497868712702473, 'fraction_numerical': 0.010571184995737426, 'mean_word_length': 7.391988555078684, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5645615', 'n_tokens_mistral': 2461, 'n_tokens_neox': 2377, 'n_words': 396}