1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115
|
### HughAI config
#
# ConfigureJavaSkirmishAI()
set(myDir "${CMAKE_CURRENT_SOURCE_DIR}")
GetLastPathPart(dirName ${myDir})
set(myName "${dirName}")
set(myLoaderSourceDir "${myDir}/src-loader")
set(myAiSourceDir "${myDir}/src-ai")
# If main Java package is "my.ai.pkg", this has to be set to "my".
GetFirstSubDirName(firstSrcSubDir ${myLoaderSourceDir})
set(myJavaPkgFirstPart "${firstSrcSubDir}")
# Check if the user wants to compile the AI
if (BUILD_Java_AIINTERFACE AND NOT myName MATCHES "${AI_EXCLUDE_REGEX}")
set(BUILD_THIS_SKIRMISHAI TRUE)
else (BUILD_Java_AIINTERFACE AND NOT myName MATCHES "${AI_EXCLUDE_REGEX}")
set(BUILD_THIS_SKIRMISHAI FALSE)
message("warning: ${myName} Skirmish AI will not be built!")
endif (BUILD_Java_AIINTERFACE AND NOT myName MATCHES "${AI_EXCLUDE_REGEX}")
# Compile and install
if (BUILD_THIS_SKIRMISHAI)
# Assemble meta data
GetVersionFromFile(myVersion "${myDir}/VERSION")
set(myLoaderTarget "${myName}-LOADER")
set(myAiTarget "${myName}-AI")
set(myLoaderSourceTarget "${myLoaderTarget}-SRC")
set(myAiSourceTarget "${myAiTarget}-SRC")
set(myInstLibsDir "${SKIRMISH_AI_LIBS}/${myName}/${myVersion}")
set(myInstDataDir "${SKIRMISH_AI_DATA}/${myName}/${myVersion}")
# CMAKE_CURRENT_BINARY_DIR: .../spring-build-dir/AI/Skirmish/${myName}
set(myBuildDir "${CMAKE_CURRENT_BINARY_DIR}")
set(myJavaLoaderBuildDir "${myBuildDir}/classes/loader")
set(myJavaAiBuildDir "${myBuildDir}/classes/ai")
set(myLoaderJarFile "SkirmishAI")
set(myAiJarFile "UnderlyingAI")
set(myLoaderBinJarFile "${myLoaderJarFile}.jar")
set(myAiBinJarFile "${myAiJarFile}.jar")
set(myLoaderSrcJarFile "${myLoaderJarFile}-src.jar")
set(myAiSrcJarFile "${myAiJarFile}-src.jar")
#set(myJLibDir "${myDir}/data/jlib")
SkirmishAIMessage(STATUS "Found Skirmish AI: ${myName} ${myVersion}")
# Create our full Java class-path
#CreateClasspath(myJavaLibs ${myJLibDir})
ConcatClasspaths(myClassPath "${CLASSPATH_Java_AIINTERFACE}" ${myAiSourceDir} ${myLoaderSourceDir} "/usr/share/java/jna.jar" "/usr/share/java/vecmath.jar")
# Create a list of all the AIs source files
file(GLOB_RECURSE myLoaderSources RELATIVE "${myLoaderSourceDir}" FOLLOW_SYMLINKS "${myLoaderSourceDir}/*.java")
file(GLOB_RECURSE myAiSources RELATIVE "${myAiSourceDir}" FOLLOW_SYMLINKS "${myAiSourceDir}/*.java")
# Compile the loader library
# needed by javac
file(MAKE_DIRECTORY "${myJavaLoaderBuildDir}")
add_custom_target(${myLoaderTarget} ALL
DEPENDS ${Java_AIINTERFACE_TARGET}
COMMAND "${JAVA_COMPILE}"
"${JAVA_COMPILE_FLAG_CONDITIONAL}"
"-classpath" "${myClassPath}"
"-d" "${myJavaLoaderBuildDir}"
${myLoaderSources}
COMMAND "${JAVA_ARCHIVE}"
"cmf" "${myDir}/manifest.mf" "${myBuildDir}/${myLoaderBinJarFile}"
"-C" "${myJavaLoaderBuildDir}" "${myJavaPkgFirstPart}"
WORKING_DIRECTORY "${myLoaderSourceDir}"
COMMENT " Creating library ${myLoaderBinJarFile}" VERBATIM)
# Compile the ai library
# needed by javac
file(MAKE_DIRECTORY "${myJavaAiBuildDir}")
add_custom_target(${myAiTarget} ALL
DEPENDS ${Java_AIINTERFACE_TARGET}
COMMAND "${JAVA_COMPILE}"
"${JAVA_COMPILE_FLAG_CONDITIONAL}"
"-classpath" "${myClassPath}"
"-d" "${myJavaAiBuildDir}"
${myAiSources}
COMMAND "${JAVA_ARCHIVE}"
"cmf" "${myDir}/manifest.mf" "${myBuildDir}/${myAiBinJarFile}"
"-C" "${myJavaAiBuildDir}" "${myJavaPkgFirstPart}"
WORKING_DIRECTORY "${myAiSourceDir}"
COMMENT " Creating library ${myAiBinJarFile}" VERBATIM)
# Pack the sources
add_custom_target(${myLoaderSourceTarget} ALL
COMMAND "${JAVA_ARCHIVE}"
"cf" "${myBuildDir}/${myLoaderSrcJarFile}"
"-C" "${myLoaderSourceDir}" "${myJavaPkgFirstPart}"
WORKING_DIRECTORY "${myLoaderSourceDir}"
COMMENT " Creating sources archive ${myLoaderSrcJarFile}" VERBATIM)
# Pack the sources
add_custom_target(${myAiSourceTarget} ALL
COMMAND "${JAVA_ARCHIVE}"
"cf" "${myBuildDir}/${myAiSrcJarFile}"
"-C" "${myAiSourceDir}" "${myJavaPkgFirstPart}"
WORKING_DIRECTORY "${myAiSourceDir}"
COMMENT " Creating sources archive ${myAiSrcJarFile}" VERBATIM)
# Install the data files
install(DIRECTORY "${myDir}/data/" DESTINATION ${myInstDataDir})
# Install the library
install (FILES "${myBuildDir}/${myLoaderBinJarFile}" DESTINATION ${myInstDataDir})
# Install the library
install (FILES "${myBuildDir}/${myAiBinJarFile}" DESTINATION ${myInstDataDir})
# Install the sources archive
install (FILES "${myBuildDir}/${myLoaderSrcJarFile}" DESTINATION ${myInstDataDir}/jlib)
# Install the sources archive
install (FILES "${myBuildDir}/${myAiSrcJarFile}" DESTINATION ${myInstDataDir}/jlib)
endif (BUILD_THIS_SKIRMISHAI)
|