summaryrefslogtreecommitdiffstats
path: root/Tests
diff options
context:
space:
mode:
authorKen Martin <ken.martin@kitware.com>2002-09-16 20:27:00 (GMT)
committerKen Martin <ken.martin@kitware.com>2002-09-16 20:27:00 (GMT)
commit885f55b3d0cfe0d1274999b44fc441967410520f (patch)
tree7ea3c5e28bf203fbd1bfadc050503c965b43b738 /Tests
parent4dec2a174a83415e9b6d26f4d0e0750111a051ef (diff)
downloadCMake-885f55b3d0cfe0d1274999b44fc441967410520f.zip
CMake-885f55b3d0cfe0d1274999b44fc441967410520f.tar.gz
CMake-885f55b3d0cfe0d1274999b44fc441967410520f.tar.bz2
load command test
Diffstat (limited to 'Tests')
-rw-r--r--Tests/LoadCommand/CMakeCommands/CMakeLists.txt4
-rw-r--r--Tests/LoadCommand/CMakeCommands/cmTestCommand.c62
-rw-r--r--Tests/LoadCommand/CMakeLists.txt31
-rw-r--r--Tests/LoadCommand/LoadedCommand.cxx8
-rw-r--r--Tests/LoadCommandOneConfig/CMakeCommands/CMakeLists.txt4
-rw-r--r--Tests/LoadCommandOneConfig/CMakeCommands/cmTestCommand.c62
-rw-r--r--Tests/LoadCommandOneConfig/CMakeLists.txt31
-rw-r--r--Tests/LoadCommandOneConfig/LoadedCommand.cxx8
8 files changed, 210 insertions, 0 deletions
diff --git a/Tests/LoadCommand/CMakeCommands/CMakeLists.txt b/Tests/LoadCommand/CMakeCommands/CMakeLists.txt
new file mode 100644
index 0000000..3a019aa
--- /dev/null
+++ b/Tests/LoadCommand/CMakeCommands/CMakeLists.txt
@@ -0,0 +1,4 @@
+PROJECT(CMAKE_LOADED_COMMANDS)
+
+INCLUDE_DIRECTORIES(${CMAKE_ROOT}/include ${CMAKE_ROOT}/Source)
+ADD_LIBRARY(cmCMAKE_TEST_COMMAND SHARED cmTestCommand.c)
diff --git a/Tests/LoadCommand/CMakeCommands/cmTestCommand.c b/Tests/LoadCommand/CMakeCommands/cmTestCommand.c
new file mode 100644
index 0000000..a4005dc
--- /dev/null
+++ b/Tests/LoadCommand/CMakeCommands/cmTestCommand.c
@@ -0,0 +1,62 @@
+#include "cmCPluginAPI.h"
+#include <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+typedef struct
+{
+ char *LibraryName;
+} cmVTKWrapTclData;
+
+
+/* do almost everything in the initial pass */
+int InitialPass(void *inf, void *mf, int argc, char *argv[])
+{
+ cmLoadedCommandInfo *info = (cmLoadedCommandInfo *)inf;
+
+ cmVTKWrapTclData *cdata =
+ (cmVTKWrapTclData *)malloc(sizeof(cmVTKWrapTclData));
+ cdata->LibraryName = "BOO";
+ info->CAPI->SetClientData(info,cdata);
+
+ // Now check and see if the value has been stored in the cache
+ // already, if so use that value and don't look for the program
+ if(!info->CAPI->IsOn(mf,"TEST_COMMAND_TEST1"))
+ {
+ info->CAPI->AddDefinition(mf, "TEST_DEF", "HOO");
+ return 1;
+ }
+
+ info->CAPI->AddDefinition(mf, "TEST_DEF", "HOO");
+ cdata->LibraryName = "HOO";
+ return 1;
+}
+
+void FinalPass(void *inf, void *mf)
+{
+ cmLoadedCommandInfo *info = (cmLoadedCommandInfo *)inf;
+ // get our client data from initial pass
+ cmVTKWrapTclData *cdata =
+ (cmVTKWrapTclData *)info->CAPI->GetClientData(info);
+ if (strcmp(info->CAPI->GetDefinition(mf, "TEST_DEF"),"HOO") ||
+ strcmp(cdata->LibraryName,"HOO"))
+ {
+ fprintf(stderr,"*** Failed LOADED COMMAND Final Pass\n");
+ }
+}
+
+CM_PLUGIN_EXPORT const char *cmGetName()
+{
+ return "CMAKE_TEST_COMMAND";
+}
+
+void CM_PLUGIN_EXPORT cmInitializeCommand(cmLoadedCommandInfo *info)
+{
+ info->InitialPass = InitialPass;
+ info->FinalPass = FinalPass;
+ info->m_Inherited = 0;
+}
+
+
+
+
diff --git a/Tests/LoadCommand/CMakeLists.txt b/Tests/LoadCommand/CMakeLists.txt
new file mode 100644
index 0000000..a200807
--- /dev/null
+++ b/Tests/LoadCommand/CMakeLists.txt
@@ -0,0 +1,31 @@
+PROJECT(LOADED_COMMANDS)
+
+# set a definition
+SET (TEST_COMMAND_TEST1 1)
+
+# try to compile the command
+TRY_COMPILE(COMPILE_OK
+ ${LOADED_COMMANDS_SOURCE_DIR}/CMakeCommands
+ ${LOADED_COMMANDS_BINARY_DIR}/CMakeCommands
+ CMAKE_LOADED_COMMANDS)
+
+# if the compile was OK, try loading the command
+IF (COMPILE_OK)
+ LOAD_COMMAND(CMAKE_TEST_COMMAND
+ ${LOADED_COMMANDS_BINARY_DIR}/CMakeCommands
+ ${LOADED_COMMANDS_BINARY_DIR}/CMakeCommands/Debug
+ )
+ # if the command loaded, execute the command
+ IF (COMMAND CMAKE_TEST_COMMAND)
+ CMAKE_TEST_COMMAND()
+ ENDIF (COMMAND CMAKE_TEST_COMMAND)
+ELSE (COMPILE_OK)
+ MESSAGE("failed to compile VTK_WRAP_TCL2")
+ENDIF (COMPILE_OK)
+
+IF (TEST_DEF)
+ ADD_DEFINITIONS(-DCMAKE_IS_FUN)
+ENDIF (TEST_DEF)
+
+ADD_EXECUTABLE (LoadedCommand LoadedCommand.cxx)
+
diff --git a/Tests/LoadCommand/LoadedCommand.cxx b/Tests/LoadCommand/LoadedCommand.cxx
new file mode 100644
index 0000000..c2a3439
--- /dev/null
+++ b/Tests/LoadCommand/LoadedCommand.cxx
@@ -0,0 +1,8 @@
+int main ()
+{
+#ifdef CMAKE_IS_FUN
+ return 0;
+#else
+ return 1;
+#endif
+}
diff --git a/Tests/LoadCommandOneConfig/CMakeCommands/CMakeLists.txt b/Tests/LoadCommandOneConfig/CMakeCommands/CMakeLists.txt
new file mode 100644
index 0000000..3a019aa
--- /dev/null
+++ b/Tests/LoadCommandOneConfig/CMakeCommands/CMakeLists.txt
@@ -0,0 +1,4 @@
+PROJECT(CMAKE_LOADED_COMMANDS)
+
+INCLUDE_DIRECTORIES(${CMAKE_ROOT}/include ${CMAKE_ROOT}/Source)
+ADD_LIBRARY(cmCMAKE_TEST_COMMAND SHARED cmTestCommand.c)
diff --git a/Tests/LoadCommandOneConfig/CMakeCommands/cmTestCommand.c b/Tests/LoadCommandOneConfig/CMakeCommands/cmTestCommand.c
new file mode 100644
index 0000000..a4005dc
--- /dev/null
+++ b/Tests/LoadCommandOneConfig/CMakeCommands/cmTestCommand.c
@@ -0,0 +1,62 @@
+#include "cmCPluginAPI.h"
+#include <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+typedef struct
+{
+ char *LibraryName;
+} cmVTKWrapTclData;
+
+
+/* do almost everything in the initial pass */
+int InitialPass(void *inf, void *mf, int argc, char *argv[])
+{
+ cmLoadedCommandInfo *info = (cmLoadedCommandInfo *)inf;
+
+ cmVTKWrapTclData *cdata =
+ (cmVTKWrapTclData *)malloc(sizeof(cmVTKWrapTclData));
+ cdata->LibraryName = "BOO";
+ info->CAPI->SetClientData(info,cdata);
+
+ // Now check and see if the value has been stored in the cache
+ // already, if so use that value and don't look for the program
+ if(!info->CAPI->IsOn(mf,"TEST_COMMAND_TEST1"))
+ {
+ info->CAPI->AddDefinition(mf, "TEST_DEF", "HOO");
+ return 1;
+ }
+
+ info->CAPI->AddDefinition(mf, "TEST_DEF", "HOO");
+ cdata->LibraryName = "HOO";
+ return 1;
+}
+
+void FinalPass(void *inf, void *mf)
+{
+ cmLoadedCommandInfo *info = (cmLoadedCommandInfo *)inf;
+ // get our client data from initial pass
+ cmVTKWrapTclData *cdata =
+ (cmVTKWrapTclData *)info->CAPI->GetClientData(info);
+ if (strcmp(info->CAPI->GetDefinition(mf, "TEST_DEF"),"HOO") ||
+ strcmp(cdata->LibraryName,"HOO"))
+ {
+ fprintf(stderr,"*** Failed LOADED COMMAND Final Pass\n");
+ }
+}
+
+CM_PLUGIN_EXPORT const char *cmGetName()
+{
+ return "CMAKE_TEST_COMMAND";
+}
+
+void CM_PLUGIN_EXPORT cmInitializeCommand(cmLoadedCommandInfo *info)
+{
+ info->InitialPass = InitialPass;
+ info->FinalPass = FinalPass;
+ info->m_Inherited = 0;
+}
+
+
+
+
diff --git a/Tests/LoadCommandOneConfig/CMakeLists.txt b/Tests/LoadCommandOneConfig/CMakeLists.txt
new file mode 100644
index 0000000..a200807
--- /dev/null
+++ b/Tests/LoadCommandOneConfig/CMakeLists.txt
@@ -0,0 +1,31 @@
+PROJECT(LOADED_COMMANDS)
+
+# set a definition
+SET (TEST_COMMAND_TEST1 1)
+
+# try to compile the command
+TRY_COMPILE(COMPILE_OK
+ ${LOADED_COMMANDS_SOURCE_DIR}/CMakeCommands
+ ${LOADED_COMMANDS_BINARY_DIR}/CMakeCommands
+ CMAKE_LOADED_COMMANDS)
+
+# if the compile was OK, try loading the command
+IF (COMPILE_OK)
+ LOAD_COMMAND(CMAKE_TEST_COMMAND
+ ${LOADED_COMMANDS_BINARY_DIR}/CMakeCommands
+ ${LOADED_COMMANDS_BINARY_DIR}/CMakeCommands/Debug
+ )
+ # if the command loaded, execute the command
+ IF (COMMAND CMAKE_TEST_COMMAND)
+ CMAKE_TEST_COMMAND()
+ ENDIF (COMMAND CMAKE_TEST_COMMAND)
+ELSE (COMPILE_OK)
+ MESSAGE("failed to compile VTK_WRAP_TCL2")
+ENDIF (COMPILE_OK)
+
+IF (TEST_DEF)
+ ADD_DEFINITIONS(-DCMAKE_IS_FUN)
+ENDIF (TEST_DEF)
+
+ADD_EXECUTABLE (LoadedCommand LoadedCommand.cxx)
+
diff --git a/Tests/LoadCommandOneConfig/LoadedCommand.cxx b/Tests/LoadCommandOneConfig/LoadedCommand.cxx
new file mode 100644
index 0000000..c2a3439
--- /dev/null
+++ b/Tests/LoadCommandOneConfig/LoadedCommand.cxx
@@ -0,0 +1,8 @@
+int main ()
+{
+#ifdef CMAKE_IS_FUN
+ return 0;
+#else
+ return 1;
+#endif
+}